esphome / esphome-core

🚨 No longer used 🚨 - The C++ framework behind ESPHome
https://esphome.io/
GNU General Public License v3.0
545 stars 113 forks source link

Not resetting effect to None, when using home assistant scenes #167

Closed TheJulianJES closed 5 years ago

TheJulianJES commented 5 years ago

Fix for this issue: #169 (Board: NodeMCUv2, esp8266, hassio esphomeyaml addon "bleeding-edge" -> currently 1.8.1)

Home Assistant scene which are not working as expected:

- name: Example_Scene_Name_NOT_Working_1
  entities:
    light.led_1_strip:
      state: on
      rgb_color: [255,0,0]
      effect: None
      brightness: 200

only changes the effect to "None" but does not change the colors.

- name: Example_Scene_Name__NOT_Working_2
  entities:
    light.led_1_strip:
      state: on
      rgb_color: [255,0,0]
      effect: Flicker"
      brightness: 200

also only changes the effect to "Flicker" but does not change the colors. (Even if we're changing back to None through e.g. the hass interface)

{"state": "ON", "effect": "None"} works and turns the effect off, as expected. {"state": "ON", "color": {"r": 0, "g": 0, "b": 255}, "brightness": 200, "effect": "None"} only changes the effect to "None". {"state": "ON", "color": {"r": 0, "g": 0, "b": 255}, "brightness": 200, "effect": "Flicker"} only changes the effect to "Flicker".

Relevant esphomeyaml config entry:

light:
  - platform: rgb
    name: "led_1_strip"
    id: leds
    red: red_output
    green: green_output
    blue: blue_output
    gamma_correct: 1.0
    effects:
      - random:
      - strobe:
      - flicker:

Log entry (when activating the scene at the top, which doesn't do anything at all):

[16:17:16][VV][component:136]: Running defer '':0 with interval=0 last_execution=0 (now=1048895)
[16:17:16][V][light.state:152]: Interpreting light JSON.
[16:17:16][V][light.light_color_values:144]: Parsing light color values JSON.
[16:17:16][V][light.light_color_values:149]:     state=ON
[16:17:16][V][light.light_color_values:155]:     brightness=0.78
[16:17:16][V][light.light_color_values:164]:     r=0.00, g=0.00, b=1.00
TheJulianJES commented 5 years ago

It seems like that the json colors are correctly parsed (which can be seen in the log) but they are not used, since we are including "effect" in the payload (see: https://github.com/OttoWinter/esphomelib/blob/master/src/esphomelib/light/light_state.cpp#L163) (Why even parsing the json for colors, if effect, ... is included?)