Workaround for light toggle

Have 2 milight bulbs in bras. Switch them on and off via a secondary input in z-wave dimmer. The problem is for this to work i have to use service: light.toggle which unlike service light on doesn’t support extra arguments.
Get an error like

17-04-13 09:12:04 ERROR (MainThread) [homeassistant.core] Invalid service data for light.toggle: extra keys not allowed @ data['brightness']. Got 255
extra keys not allowed @ data['color_temp']. Got 294
17-04-13 09:12:06 ERROR (MainThread) [homeassistant.core] Invalid service data for light.toggle: extra keys not allowed @ data['brightness']. Got 255
extra keys not allowed @ data['color_temp']. Got 294

So what can be a work around to overcome this? service_template for light on and off depending on the template state of light? Or maybe there are better ways?

- alias: Bedroom Bra left
  trigger:
    platform: event
    event_type: zwave.scene_activated
    event_data:
      entity_id: fibaro_system_fgd212_dimmer_2_10
      scene_id: 26
  action:
    service: light.toggle
    entity_id: light.bed_bra_l
#    data:
#      color_temp: 294
#      brightness: 255

Tried it like this. But get the error on extra keys not allowed for the light.turn_off
Now i am lost. Is there a way to separate data for different services? Two automation rules with different conditions?

  action:
  - service_template: >
      {% if is_state('light.bed_bra_r', 'on') %}
        light.turn_off
      {% else %}
        light.turn_on
      {% endif %}
    entity_id: light.bed_bra_r
    data:
      color_temp: 294
      brightness: 255

Heres how I’ve done it. might be a nicer way of doing it. I’m sure there is. It checks to see what state it thinks it is in (not always correct with milights but more often than not correct). Just need to add whatever you need into this (eg temp and brightness)

- alias: Toggle Moos Light on
  hide_entity: True
  trigger:
    platform: event
    event_type: click
    event_data:
        entity_id: binary_sensor.switch_158d00013f81f8
        click_type: single
  condition:
    condition: state
    entity_id: light.moosroom
    state: 'off'
  action:
    service: light.turn_on
    data:
      entity_id: light.moosroom
      color_name: white

- alias: Toggle moos Light off
  hide_entity: True
  trigger:
    platform: event
    event_type: click
    event_data:
        entity_id: binary_sensor.switch_158d00013f81f8
        click_type: single
  condition:
    condition: state
    entity_id: light.moosroom
    state: 'on'     
  action:
    service: light.turn_off
    data:
      entity_id: light.moosroom
1 Like