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

event.fire and state.set send context if provided #60

Merged
merged 1 commit into from
Oct 28, 2020

Conversation

dlashua
Copy link
Contributor

@dlashua dlashua commented Oct 28, 2020

Test with:

from homeassistant.core import Context


@state_trigger(['input_boolean.test_1'])
def test_state_trigger(**data):
    log.info(data)
    new_context = Context(parent_id=data['context'].id)
    state.set('binary_sensor.test', 'on', context=new_context)

@state_trigger(['binary_sensor.test'])
def test_context_sent(**data):
    log.info(data)

@event_trigger('PYSCRIPT_TEST')
def test_event_trigger(**data):
    log.info(data)
    new_context = Context(parent_id=data['context'].id)
    event.fire('PYSCRIPT_TEST2', context=new_context)

@event_trigger('PYSCRIPT_TEST2')
def test_context_sent_event(**data):
    log.info(data)

data logged by test_context_sent_event and test_context_sent should show parent_id of the received context.

@craigbarratt craigbarratt merged commit 69d02ec into custom-components:master Oct 28, 2020
@craigbarratt
Copy link
Member

Looks great - thanks!

@dlashua dlashua deleted the send-context branch October 28, 2020 22:02
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.

None yet

2 participants