Coder Social home page Coder Social logo

Comments (27)

uvjustin avatar uvjustin commented on August 24, 2024

Can you share your configuration.yaml?

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

Here you go, I've 'redacted' identifiable items

Note my config for the alarmdotcom is very very basic

  • platform: alarmdotcom
    username: !secret alarmdotcom_username
    password: !secret alarmdotcom_password

Its an account that I use is a login that created just for HA. Permission is custom with the following permissions enabled

  • Remote Arming
  • Activity
homeassistant:
  auth_providers:
    - type: homeassistant
  # Name of the location where Home Assistant is running
  name:  [REDACTED]
  # Location required to calculate the time the sun rises and sets
  latitude:  [REDACTED]
  longitude:  [REDACTED]
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 346
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: America/Toronto
  # Customization file
  customize: !include customize.yaml
  external_url:  [REDACTED]
  internal_url:  [REDACTED]

logger:
  default: warning
  logs:
    custom_components.aarlo: critical
    homeassistant.components.waze_travel_time: critical
    pyaarlo: critical
#    custom_components.alarmdotcom: debug

# Enables the frontend
frontend:


# Enables the auth component
auth: 

# Enables configuration UI
config:


http:
  #base_url:  [REDACTED]
  #ssl_certificate: /ssl/fullchain.pem
  #ssl_key: /ssl/privkey.pem
  #server_port: 443
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1
    - 172.30.33.0/24
  # Secrets are defined in the file secrets.yaml
  # api_password: !secret http_password
  # Uncomment this if you are using SSL/TLS, running in Docker container, etc.
  # base_url: example.duckdns.org:8123
    

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
  # Optional, allows Home Assistant developers to focus on popular components.
  include_used_components: true

# Discover some devices automatically
discovery:


system_health:

# Enables support for tracking state changes over time
history:

person:

recorder:
  db_url:  [REDACTED]
  auto_purge: false
  purge_keep_days: 7
  exclude:
    entities:
      - sun.sun
      - sensor.moon
      - sensor.time
      - sensor.date
      - switch.great_room
      - switch.family_room
      - switch.master_vestibule
      - sensor.air_quality_health_index
      - sensor.chance_of_precip
      - sensor.condition
      - sensor.high_temperature
      - sensor.humidex
      - sensor.low_temperature
      - sensor.pressure
      - sensor.uv_index
      - sensor.visibility
      - sensor.wind_chill
      - sensor.wind_bearing
      - sensor.wind_speed
      - sensor.wind_direction
      - sensor.wind_gust
    entity_globs:
      - camera.*
      - weather.*
      - zone.*
      - script.*
      - automation.*
      - media_player.*
  
# View all events in a logbook
logbook:
  exclude:
    domains:
      - media_player
      - group
      - scene
      - zone
    entities:
      - sensor.time
      - sensor.date
      - alarm_control_panel.aarlo_arlo_base_station
      - switch.great_room
      - switch.family_room
      - switch.master_vestibule

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# Enable mobile app
mobile_app:


# enable nest  
nest:
  client_id:  [REDACTED]
  client_secret:  [REDACTED]

# enable bad nest
badnest:
  user_id: 525855
  access_token:  [REDACTED]
  region: us

# sensor
sensor:
  - platform: moon
  - platform: time_date
    display_options:
      - 'date'
      - 'time'
  - platform: environment_canada
  - platform: systemmonitor
    resources:
      - type: memory_use_percent
      - type: processor_use
      - type: disk_use_percent
        arg: /home
    scan_interval: 600
  - platform: season
  - platform: waze_travel_time
    name: Time Home Joe
    region: NA
    #api_key:  [REDACTED]
    origin: person.joe_preiditsch
    destination: zone.home
  - platform: waze_travel_time
    name: Time Home Sarah
    region: NA
    #api_key:  [REDACTED]
    origin: person.sarah_preiditsch
    destination: zone.home
  - platform: command_line
    name: Processor Temperature
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    unit_of_measurement: "°C"
    value_template: '{{ value | multiply(0.001) | round(1) }}'
    scan_interval: 600
  - platform: dnsip
  - platform: dnsip
    hostname:  [REDACTED]
    name: hassio
    resolver: 1.1.1.1
  - platform: command_line
    name: Energy Period
    command: "python3 /config/scripts/oeb.py"
    json_attributes:
      - rate
    value_template: '{{ value_json.period }}'
    scan_interval: 300
  - platform: command_line
    name: Water Price
    command: "python3 /config/scripts/kitchenerutilities.py"
    json_attributes:
      - sewer_rate
      - gas_rate
    value_template: '{{ value_json.water_rate }}'
    unit_of_measurement: "$/kL"       
    scan_interval: 14400   
  - platform: command_line
    name: Phone
    command: "python3 /config/scripts/ht801.py"
    json_attributes:
      - reg_status
    value_template: '{{ value_json.line_status }}'
    scan_interval: 30   
  - platform: command_line
    name: Region of Waterloo Covid Cases
    command: "python3 /config/scripts/covid.py"
    json_attributes:
      - date
      - total
    value_template: '{{ value_json.count }}'
    unit_of_measurement: "Cases"
    scan_interval: 3600           
  - platform: neurio_energy
    api_key:  [REDACTED]
    api_secret:  [REDACTED]
    sensor_id:  [REDACTED]
    scan_interval: 60
  - platform: template
    sensors:
      energy_price:
        friendly_name: 'Energy Price'
        value_template: >-
          {{ state_attr('sensor.energy_period', 'rate') }}
        unit_of_measurement: "¢/kWh"
      energy_cost:
        friendly_name: 'Energy Cost'
        value_template: >-
          {{ ((states('sensor.energy_usage') | float /1000) * states('sensor.energy_price') | float) | float | round(2) }}
        unit_of_measurement: "¢/h"  
      water_usage:
        friendly_name: 'Water Usage'
        value_template: >-
          {{ (states('sensor.flume_water_current_gal') | float * 3.78541) | float | round(2) }}
        unit_of_measurement: "L/m"  
      daily_water_usage:
        friendly_name: 'Daily Water Usage'
        value_template: >-
          {{ (states('sensor.flume_water_current_day_gal') | float * 3.78541) | float | round(2) }}
        unit_of_measurement: "L"     
      water_cost:
        friendly_name: 'Water Cost'
        value_template: >-
          {{ (((states('sensor.flume_water_60_minutes_gal') | float * 3.78541 )  *  states('sensor.water_total_price') | float) /10) | round(2)  }}
        unit_of_measurement: "¢/h"          
      sewer_price:
        friendly_name: 'Sewer Price'
        value_template: >-
          {{ state_attr('sensor.water_price', 'sewer_rate') }}
        unit_of_measurement: "$/kL"
      water_total_price:
        friendly_name: 'Water Total Price'
        value_template: >-
          {{ (state_attr('sensor.water_price', 'sewer_rate') + states('sensor.water_price') | float) | round(4) }}
        unit_of_measurement: "$/kL"        
      natural_gas_price:
        friendly_name: 'Natural Gas Price'
        value_template: >-
          {{ state_attr('sensor.water_price', 'gas_rate') }}
        unit_of_measurement: "¢/kL"        
      great_room_fireplace_humidity:
        friendly_name: 'Great Room Fireplace Humidity'
        device_class: humidity
        value_template: >-
          {{ state_attr('climate.great_room_fireplace', 'current_humidity') }}
        unit_of_measurement: "%"        
      ontario_covid_cases:
        friendly_name: 'Ontario Covid Cases'
        value_template: >-
          {{ state_attr('sensor.region_of_waterloo_covid_cases', 'total') }}
        unit_of_measurement: "Cases"
        
  - platform: badnest
    
    
# binary sensor
binary_sensor:
  - platform: workday
    country: CA
    province: 'ON'
  - platform: template
    sensors:
      back_door:
        device_class: door
        friendly_name: 'Back Door'
        value_template: >-
          {{ state_attr('alarm_control_panel.alarm_com', 'sensor_status') | regex_search('Back Door is Open', ignorecase=TRUE) }}
      front_door:
        device_class: door
        friendly_name: 'Front Door'
        value_template: >-
          {{ state_attr('alarm_control_panel.alarm_com', 'sensor_status') | regex_search('Front Door is Open', ignorecase=TRUE) }} 
      left_balcony_door:
        device_class: door
        friendly_name: 'Left Balcony Door'
        value_template: >-
          {{ state_attr('alarm_control_panel.alarm_com', 'sensor_status') | regex_search('Upstairs Door Front is Open', ignorecase=TRUE) }} 
      right_balcony_door:
        device_class: door
        friendly_name: 'Right Balcony Door'
        value_template: >-
          {{ state_attr('alarm_control_panel.alarm_com', 'sensor_status') | regex_search('Upstairs Door Back is Open', ignorecase=TRUE) }}
      garage_door:
        device_class: door
        friendly_name: 'Garage Door'
        value_template: >-
          {{ state_attr('alarm_control_panel.alarm_com', 'sensor_status') | regex_search('Garage Door is Open', ignorecase=TRUE) }}
      foyer_motion:
        device_class: motion
        friendly_name: 'Foyer motion'
        value_template: >-
          {{ state_attr('alarm_control_panel.alarm_com', 'sensor_status') | regex_search('Motion Detector is Activated', ignorecase=TRUE) }}
      recreation_room_motion:
        device_class: motion
        friendly_name: 'Recreation Room motion'
        value_template: >-
          {{ state_attr('alarm_control_panel.alarm_com', 'sensor_status') | regex_search('Motion Detector Basement is Activated', ignorecase=TRUE) }}    
      water_flow:
        device_class: opening
        friendly_name: "Water Flow"
        value_template: >-
          {{ states.sensor.flume_water_current_gal.state != "0" }}

      
# Example configuration.yaml entry
weather:
  - platform: environment_canada

# Enable arlo
aarlo:
  username: !secret aarlo_username
  password: !secret aarlo_password


ffmpeg:

 
camera:
  - platform: aarlo
    ffmpeg_arguments: '-pred 1 -q:v 2'
  - platform: environment_canada
    name: 'Weather'

# alarm
alarm_control_panel:
  - platform: aarlo
    home_mode_name: Home
    away_mode_name: Away
    code_arm_required: false
  - platform: alarmdotcom
    username: !secret alarmdotcom_username
    password: !secret alarmdotcom_password
      
      
stream:    

apple_tv:
      
# liftmaster
cover:
  - platform: myq
    username: !secret myq_username
    password: !secret myq_password
    
ecovacs:
  username: !secret ecovacs_username
  password: !secret ecovacs_password
  country: ca
  continent: na
    

# tts
tts:
  - platform: google_translate
    service_name: google_say
    language: 'en'
    base_url: [REDACTED]
    

# rest commands 
rest_command:
  dnsomatic:
    url: 'https://updates.dnsomatic.com/nic/update?hostname=all.dnsomatic.com'
    method: get
    username: !secret dnsomatic_username
    password: !secret dnsomatic_password
    
device_tracker:
  - platform: trackr
    username: !secret trackr_joe_username
    password: !secret trackr_joe_password
    scan_interval: 300
  - platform: trackr
    username: !secret trackr_sarah_username
    password: !secret trackr_sarah_password
    scan_interval: 300
  
    
google_assistant: !include google_assistant.yaml
alexa: !include alexa.yaml
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
zone: !include zones.yaml

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

Oh, I was actually just looking for the alarm_control_panel section.
It's strange that your logs say
2020-12-15 12:48:13 WARNING (MainThread) [homeassistant.components.alarm_control_panel] Setup of alarm_control_panel platform alarmdotcom is taking over 10 seconds. 2020-12-15 12:48:13 WARNING (MainThread) [homeassistant.components.alarm_control_panel] Setup of alarm_control_panel platform alexa_media is taking over 10 seconds.
When the two platforms should be aarlo and alarmdotcom. Is everything else in your system working well?
Since you are using such a basic alarmdotcom config, I can't see why anything would change between version 0.1.6 and subsequent versions.

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

Everything else is working fine in my system.
I do normally see the same weird message about the alexa load.

Here's the snippet of the logs when I'm using 0.1.6 of the component

2020-12-15 12:58:02 WARNING (MainThread) [homeassistant.components.alarm_control_panel] Setup of alarm_control_panel platform alarmdotcom is taking over 10 seconds.
2020-12-15 12:58:02 WARNING (MainThread) [homeassistant.components.alarm_control_panel] Setup of alarm_control_panel platform alexa_media is taking over 10 seconds.
2020-12-15 12:58:03 ERROR (MainThread) [pyalarmdotcomajax.pyalarmdotcomajax] Can not load login page from Alarm.com

The main difference is that I don't see the platform load error log
Have any dependencies changed or was there something changed with that specific TypeError message at the bottom of the log. Perhaps the old version was more lenient to the deserialization??

2020-12-15 12:48:23 ERROR (MainThread) [homeassistant.components.alarm_control_panel] Error while setting up alarmdotcom platform for alarm_control_panel
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/alarmdotcom/alarm_control_panel.py", line 95, in async_setup_platform
    await alarmdotcom.async_login()
  File "/config/custom_components/alarmdotcom/alarm_control_panel.py", line 155, in async_login
    await self._alarm.async_login()
  File "/usr/local/lib/python3.8/site-packages/pyalarmdotcomajax/pyalarmdotcomajax.py", line 202, in async_login
    await self._async_get_system_info()
  File "/usr/local/lib/python3.8/site-packages/pyalarmdotcomajax/pyalarmdotcomajax.py", line 160, in _async_get_system_info
    async with self._websession.get(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1124, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 549, in _request
    resp = await req.send(conn)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 668, in send
    await writer.write_headers(status_line, self.headers)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py", line 118, in write_headers
    buf = _serialize_headers(status_line, headers)
  File "aiohttp/_http_writer.pyx", line 137, in aiohttp._http_writer._serialize_headers
  File "aiohttp/_http_writer.pyx", line 109, in aiohttp._http_writer.to_str
**TypeError: Cannot serialize non-str key None**

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

The snipped from 0.1.6 looks like it just failed to log in.
With 0.1.8 it looks like it is partially logging in and then getting stuck.
Can you check that you can actually log in to the portal with that username? Some users have reported that their providers are requiring 2FA on the logins, and that's the main reason for the updates to the component in the past few weeks. Which ADC provider do you use?

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

I just quickly tried logging into ADC's web site with the credentials I use for the integration and it didn't request 2FA.

The provider is Telus

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

Did the integration ever work for you?
If not, it's possible Telus has a slightly different interface than the ones we've seen before. If you want me to look into it more, you can make a temporary login for me to have a look.
I've posted a PGP key here. You can post the encrypted login here or you can PM me on the HA community forum.
#21 (comment)

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

I've been using your version of the integration as long as the official integration was dropped. its been working flawlessly.
I currently have it working but only when I download the custom component from girhut at this commit

https://github.com/uvjustin/alarmdotcom/tree/190a59261020593ce2b347940f783ed454e2b4aa

It stopped working when I updated in Hacs a bit back, so I reverted to the one above. When yesterday's release came out I updated in hacs again and it broke. So I reverted to the above and it started to work. Its pretty easy for me to just swap out the custom component between head of master and the old commit cause it to break or work.
PM is coming your way

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

I just tried the login you sent me and was able to log in with no problems. What kind of HA install are you running and what version are you on?

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

For troubleshooting, you can try logging in with the library itself outside of HA using the following code (fill in your username and password):

from pyalarmdotcomajax import Alarmdotcom
import asyncio
import aiohttp


async def main():
  username="YOUR_USERNAME"
  password="YOUR_PASSWORD"
  async with aiohttp.ClientSession() as session:
    adc = Alarmdotcom(username,password,session,False,False,False,None)
    await adc.async_login()
    await adc.async_update()
  print(adc.state)
  print(adc.sensor_status)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

I see your config has several other files included at the bottom. Does one of those files have another alarm_control_panel: section? Can you check the configuration.yaml as instructed here? https://www.home-assistant.io/docs/configuration/troubleshooting/

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

I see your config has several other files included at the bottom. Does one of those files have another alarm_control_panel: section? Can you check the configuration.yaml as instructed here? https://www.home-assistant.io/docs/configuration/troubleshooting/

Check config always passes.
The additional files don’t define any integrations except for extracting my google assistant and Alexa configs out to their own files (their customization is longer than my main config :/)

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

It's still strange that there's an alarm platform named alexa_media in your logs.
Does the code snippet to test the library itself work on your system?

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

my pi isn't configured for root ssh access. I actually don't have pysical access to it at the moment. I never ended up getting the import settings to enable it before injuring my back.
I downloaded the alarmdotcomajax library and aio http 3.7.1 and latest beautifulsoup4 to my mac and ran the script with the credentials that I use and it returns the following.

disarmed
System OK, Back Door is Closed, Fire Detector is Not Reset, Front Door is Closed, Garage Door is Closed, Motion Detector is Idle, Motion Detector Basement is Idle, Upstairs Door Back is Closed, Upstairs Door Front is Closed

So it definitely seems to be environment related or something specific to how HA is making the request.
alexa_media is the latest version of the alexa media player from hacs. Maybe its trying to expose alexa guard as an alarm control panel.

maybe its not the underlying library itself but something in the integration code?

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

We'll see about compatibility but I'm going to try to utilize the older version with the updated alarmdotcomajax dependency for fun..

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

Yeah that change I made did not work lol I'll play around a bit more and let you know if I see anything

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

File "aiohttp/_http_writer.pyx", line 137, in aiohttp._http_writer._serialize_headers
File "aiohttp/_http_writer.pyx", line 109, in aiohttp._http_writer.to_str
TypeError: Cannot serialize non-str key None
Which makes me wonder why its trying to send none in the writer instead of a value

In the ajax config I see this

self._twofactor_cookie = (
            {"twoFactorAuthenticationId": twofactorcookie} if twofactorcookie else {}
        )

It almost looks like the component is trying to serialize a null value instead of not sending the parameter.

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

So I got it working in a really funny manner

Changed

  - platform: alarmdotcom
    username: !secret alarmdotcom_username
    password: !secret alarmdotcom_password
      

to

  - platform: alarmdotcom
    username: !secret alarmdotcom_username
    password: !secret alarmdotcom_password
    two_factor_cookie: ""

I played around in the component and found this by playing around a bit

Original

self._alarm = adc_class(
            username,
            password,
            websession,
            force_bypass,
            no_entry_delay,
            silent_arming,
            two_factor_cookie,
        )

changed it to

self._alarm = adc_class(
            username,
            password,
            websession,
            force_bypass,
            no_entry_delay,
            silent_arming,
            None,
        )

Which did not work
So I changed it to

self._alarm = adc_class(
            username,
            password,
            websession,
            force_bypass,
            no_entry_delay,
            silent_arming,
            "",
        )

And this did work.

So then I then reverted updated the config with the empty string and it worked fine.

Perhaps there is some other component pulling in a dependency that is causing the issue.
My system config

System Health

version 2020.12.0
installation_type Home Assistant OS
dev false
hassio true
docker true
virtualenv false
python_version 3.8.6
os_name Linux
os_version 5.4.79-v8
arch aarch64
timezone America/Toronto
Home Assistant Community Store
GitHub API ok
Github API Calls Remaining 4786
Installed Version 1.9.0
Stage running
Available Repositories 685
Installed Repositories 4
Hass.io
host_os Home Assistant OS 5.8
update_channel stable
supervisor_version 2020.12.7
docker_version 19.03.13
disk_total 28.6 GB
disk_used 6.2 GB
healthy true
supported true
board rpi3-64
supervisor_api ok
version_api ok
installed_addons Samba share (9.3.0), Terminal & SSH (8.10.0), AirCast (2.4.1), AirSonos (2.4.1), Let's Encrypt (4.11.0), File editor (5.2.0), NGINX Home Assistant SSL proxy (3.0.1), Home Assistant Google Drive Backup (0.102.0), MariaDB (2.2.1)
Lovelace
dashboards 1
mode storage
views 1
resources 0

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

That's strange. I could easily change the config parameter to default to "" (I had actually previously considered doing so based on what is written here: https://developers.home-assistant.io/docs/development_validation/ , but that suggests just not specifying None explicitly as a default and doesn't say anything about always providing a default. If you look through the code base most usages of vol.Optional() don't specify defaults).
Anyway, it's not clear why using None should be an issue. That ternary line you posted is designed to receive a None and should set the variable to an empty dict. It looks like in your case it is evaluating the other way and returning a dict of {"twoFactorAuthenticationId": None}. No idea what is going on with that. I'll see if anyone reports something similar and whether we can find out what's happening.

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

Really reviewing the code there didn't seem to be anything wrong with it at all. It seems mostly environment or possibly a different version of the async io library included by another integration.
Possibly some additional explicit tightening of the conditions could be added... note I'm not a python expert at all but I can read and follow the code

Maybe change it up some how to not send the cookies parameter if None was passed in. It could be the serialization of the empty dictionary is handled differently. But yeah this is really strange.

Thanks again for the assistance on this. I've updated to the very latest release from hacs (I think you just updated the readme) but it still works with my goofy empty string for the two_factor_cookie

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

Haven't heard of any other reports on this yet so it's probably something related to your install. I think the Alexa component uses a custom aiohttp which handles cookies differently - there's a decent chance the issue here is related to that. Since you've found a workaround and there doesn't seem to be an obvious problem with this component, I'm closing this for now.

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

@uvjustin I've realized the issue only occurs when the home assistant log shows this after starting.
"Can not load system data from Alarm.com"

I think the refactoring of the async_login to into
_async_get_ajax_key
_async_get_system_info
Might have caused the issue to appear

async_system_info call might still be happening after failing to load the login page instead of just returning from async_login if async_get_ajax_key would have normally returned false.

If the _async_get_ajax_keydidnot work the values of the ajax headers would be

self._ajax_headers = {
            "Accept": "application/vnd.api+json",
            "ajaxrequestuniquekey": None,
        }

and the web call to

 async def _async_get_system_info(self):
        try:
            # grab system id
            async with self._websession.get(
                url=self.SYSTEMITEMS_URL, headers=self._ajax_headers
            ) 

Would still have the none value in the headers which corresponds to the stack trace with the error on line 160 that I first reported.

2020-12-15 12:48:23 ERROR (MainThread) [homeassistant.components.alarm_control_panel] Error while setting up alarmdotcom platform for alarm_control_panel
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/alarmdotcom/alarm_control_panel.py", line 95, in async_setup_platform
await alarmdotcom.async_login()
File "/config/custom_components/alarmdotcom/alarm_control_panel.py", line 155, in async_login
await self._alarm.async_login()
File "/usr/local/lib/python3.8/site-packages/pyalarmdotcomajax/pyalarmdotcomajax.py", line 202, in async_login
await self._async_get_system_info()
File "/usr/local/lib/python3.8/site-packages/pyalarmdotcomajax/pyalarmdotcomajax.py", line 160, in _async_get_system_info
async with self._websession.get(

File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1124, in aenter
self._resp = await self._coro
File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 549, in _request
resp = await req.send(conn)
File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 668, in send
await writer.write_headers(status_line, self.headers)
File "/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py", line 118, in write_headers
buf = _serialize_headers(status_line, headers)
File "aiohttp/_http_writer.pyx", line 137, in aiohttp._http_writer._serialize_headers
File "aiohttp/_http_writer.pyx", line 109, in aiohttp._http_writer.to_str
TypeError: Cannot serialize non-str key None

The issue only seems to happen if the login fails when first starting up preventing the component from loading.

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

You're right about the problem from refactoring. Thanks for pointing that out. I will fix that now.

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

Made the change, see if it fixes the issue on your end.

from alarmdotcom.

jpreiditsch avatar jpreiditsch commented on August 24, 2024

I've pulled in the update and so far so good. Its behaving. My HA is scheduled to restart every morning so we'll see.
The error was intermittent so it definitely was a tough one to track down.
Thanks for the fix.

from alarmdotcom.

uvjustin avatar uvjustin commented on August 24, 2024

Great. Thanks for digging in and tracking down the problem.

from alarmdotcom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.