Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cant seem to get state_trigger to work with numeric identifier switch #234

Unanswered
hobbit44 asked this question in Q&A
Discussion options

This doesnt work (not unexpectedly):

log.debug(switch.44625077dc4f225ae658)
>>>
Exception in <jupyter_0> line 1:
 switch.44625077dc4f225ae658.turn_on()
 ^
SyntaxError: invalid syntax (jupyter_0, line 1)

but this does:

log.debug(state.get("switch.44625077dc4f225ae658"))
>>>
on

So i want to do a state trigger like the following, but gets the same issue:

@state_trigger("switch.44625077dc4f225ae658 == 'on'")
def test():
 log.debug('Hello World!')
>>>
Exception in <jupyter_0.test @state_trigger()> line 1:
 switch.44625077dc4f225ae658 == 'on'
 ^
SyntaxError: invalid syntax (jupyter_0.test @state_trigger(), line 1)

These 2 are accepted but arent actually being triggered:

@state_trigger("switch.44625077dc4f225ae658")
or
@state_trigger("state.get('switch.44625077dc4f225ae658') == 'on'")

Anyone know the best way to get around this?

You must be logged in to vote

Replies: 1 comment

Comment options

The issue is that pyscript is having trouble figuring out which entities to watch when state.get() is in the trigger condition. You can get around it with the watch argument to state_trigger. Like this:

@state_trigger('state.get("input_boolean.1_test") == "on"', watch=['input_boolean.1_test'])
def test_on():
 log.info('on')
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /