Skip to content

Comments

Fix default sensor variables in homio_room template#30

Open
isaacrushworth2002 wants to merge 1 commit intoiamtherufus:mainfrom
isaacrushworth2002:main
Open

Fix default sensor variables in homio_room template#30
isaacrushworth2002 wants to merge 1 commit intoiamtherufus:mainfrom
isaacrushworth2002:main

Conversation

@isaacrushworth2002
Copy link

The default values for motion_sensor, temp_sensor, and humid_sensor were set to the literal strings "variables.motion_sensor", "variables.temp_sensor", and "variables.humid_sensor" respectively.

When a user doesn't provide these sensor variables (e.g. setting show_temp: false without a temp_sensor), the JavaScript template checks like if (!variables.motion_sensor) evaluate as truthy because they contain non-empty strings. This then causes the template to attempt states["variables.motion_sensor"] which throws:

ButtonCardJSTemplateError: Cannot read properties of undefined (reading 'state')

Changed the defaults to empty strings so the falsy checks work correctly when sensors aren't provided.

The default values for motion_sensor, temp_sensor, and humid_sensor were set to the literal strings "variables.motion_sensor", "variables.temp_sensor", and "variables.humid_sensor" respectively.

When a user doesn't provide these sensor variables (e.g. setting show_temp: false without a temp_sensor), the JavaScript template checks like `if (!variables.motion_sensor)` evaluate as truthy because they contain non-empty strings. This then causes the template to attempt `states["variables.motion_sensor"]` which throws:

ButtonCardJSTemplateError: Cannot read properties of undefined (reading 'state')

Changed the defaults to empty strings so the falsy checks work correctly when sensors aren't provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant