Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default zigbee2mqtt names for entities lead to invalid syntax for state triggers #180

Closed
sfiel opened this issue Mar 6, 2021 · 1 comment

Comments

@sfiel
Copy link

sfiel commented Mar 6, 2021

Hi,

By default zigbee2mqtt names the entities according to their address, but when using these names for example as state_trigger it is an invalid syntax:

@state_trigger("binary_sensor.0x00158d0003946123_occupancy == 'on'")
def test():
    log.info('test')

leads to

    binary_sensor.0x00158d0003946123_occupancy == 'on'
                 ^
SyntaxError: invalid syntax (scripts.motion_senors.hallway.test @state_trigger(), line 1)

when I rename the entiy for example to binary_sensor.living_room_occupancy it works as expected.

pyscript: 1.3.1
home assistant: 2021.2.3

Cheers,
Stefan

P.S.: thanks for your efforts!

@craigbarratt
Copy link
Member

craigbarratt commented Mar 6, 2021

This is issue #165. Since python is parsing the code, it doesn't allow literals that start with digits. Starting in 1.3.0 the watch keyword was added, so you can use state.get inside a trigger expression, and watch to tell it what variables to monitor:

@state_trigger("state.get('binary_sensor.0x00158d0003946123_occupancy') == 'on'", watch=["binary_sensor.0x00158d0003946123_occupancy"])
def test():
    log.info('test')

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

No branches or pull requests

2 participants