i3detroit / homeassistant-config

home assistant configuration files
https://www.i3detroit.org/wiki/Category:IoT
1 stars 1 forks source link

add hex rgb support #13

Closed abzman closed 6 years ago

abzman commented 6 years ago

needed for tasmota rgb lights

mkfink commented 6 years ago

Wrote a workaround that works and only generates error messages in home assistant when scheme/effect is changed. See rgb_value_template below, which is set up for RGB. Swap the indices around for GRB or whatever support.

Explanation in case some poor soul runs across this:


  name: Elab Arch South
  effect_list:
    - 2
    - 3
  state_topic: "stat/i3/inside/elab/accent/arch-south/RESULT"
  command_topic: "cmnd/i3/inside/elab/accent/arch-south/POWER"
  brightness_state_topic: "stat/i3/inside/elab/accent/arch-south/RESULT"
  brightness_command_topic: "cmnd/i3/inside/elab/accent/arch-south/Dimmer"
  brightness_scale: 100
  rgb_command_template: "{{ '%02x%02x%02x00' | format(red, green, blue)}}"
  rgb_state_topic: "stat/i3/inside/elab/accent/arch-south/RESULT"
  rgb_command_topic: "cmnd/i3/inside/elab/accent/arch-south/Color"
  effect_command_topic: "cmnd/i3/inside/elab/accent/arch-south/Scheme"
  effect_state_topic: "stat/i3/inside/elab/accent/arch-south/RESULT"
  state_value_template: >
    {% if "POWER" in value_json %}
      {{ value_json.POWER }}
    {% endif %}
  brightness_value_template: >
    {% if "Dimmer" in value_json %}
      {{ value_json.Dimmer }}
    {% endif %}
  effect_value_template: >
    {% if "Scheme" in value_json %}
      {{ value_json.Scheme }}
    {% endif %}
  rgb_value_template: >
    {% if "Color" in value_json %}
      {{ (value_json.Color[0:2] | int(int, 16)) | string + ',' + (value_json.Color[2:4] | int(int, 16)) | string + ',' + (value_json.Color[4:6] | int(int, 16)) | string }}
    {% endif %}
  payload_on: "ON"
  payload_off: "OFF"
  on_command_type: "brightness"