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

Add native ESPHome API service call feature #19401

Merged
merged 2 commits into from Dec 17, 2018

Conversation

Projects
None yet
4 participants
@OttoWinter
Copy link
Contributor

OttoWinter commented Dec 17, 2018

Description:

One of the features that ESPHome will finally be able to solve with the native API is the problem of inter-device automations. Up until now, if the user wanted an automation that interacts with anything else the user would have to use HA automations for this.

With this change, users can add something like this to their ESPHome automations:

binary_sensor:
- platform: gpio
  pin: D1
  on_press:
  # On-device automation
  - switch.turn_on: my_switch
  - delay: 1s
  # HA service call
  - homeassistant.service:
      service: notify.html5
      data:
        title: Button was pressed
      data_template:
        message: The humidity is {{ my_variable }}%.
      variables:
        my_variable: 'return id(my_sensor).state;'

TODO:

  • This calls services directly using hass.services.async_call. I've seen the Context class used in several places in the HA codebase. Should this integration also use Contexts? If so, how should that be done? CC @balloob

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
@balloob

This comment has been minimized.

Copy link
Member

balloob commented Dec 17, 2018

OttoWinter added some commits Dec 17, 2018

@OttoWinter OttoWinter force-pushed the OttoWinter:esphome-service-call branch from 01a8df6 to 62106b4 Dec 17, 2018

@OttoWinter OttoWinter merged commit 4ffacec into home-assistant:dev Dec 17, 2018

3 of 4 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
Hound 5 violations found.
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA

@OttoWinter OttoWinter deleted the OttoWinter:esphome-service-call branch Dec 17, 2018

dshokouhi added a commit to dshokouhi/home-assistant that referenced this pull request Dec 25, 2018

Add native ESPHome API service call feature (home-assistant#19401)
* Add native ESPHome API service call feature

* 🚑 Fix

@balloob balloob referenced this pull request Jan 10, 2019

Merged

0.85.0 #19897

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment