Set state of switch other then ON or OFF in via automation

Hello,

In the frontend under developer tools, on the tab “states”, there is an option to set the state of a switch other then ON or OFF. An custom value like “neutral” is accepted.

I would like to know if it is possible to set the state of a switch into “neutral” via an automation.

The reason to do this is because i want to use only the ON button on my wall mounted 433mhz switch to toggle my kitchen lichts ON or OFF. via an automation.

The reason only to want to use the ON button in this case is because the lights in te kitchen are also set On or OFF via Google cast devices. Therefore i never know witch button to push on my wall mounted switch to turn the lights ON if a Cast device has set the lights of.
(The functions on the wall mounted switch flip. 50% of the time I have to press the OFF button to turn on the lights). That is very annoying.

This is the code i use now:

- id: '1597736447919'
  alias: Keuken werkblad Omschakelen met knop
  description: ''
  trigger:
  - entity_id: switch.ac_196577a_12
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: switch.ac_196577a_12
    from: 'on'
    platform: state
    to: 'off'
  condition: []
  action:
  - device_id: fb6472741ff44afe8cc5d2f41771bc59
    domain: light
    entity_id: light.keuken_werkblad_1
    type: toggle
  - device_id: 16fadc5b0fb04986b302efb339cbd4c9
    domain: light
    entity_id: light.keuken_werkblad_2
    type: toggle
  mode: single

And I would like it to change into something like this:

- id: '1597736447919'
  alias: Keuken werkblad Omschakelen met knop
  description: ''
  trigger:
  - entity_id: switch.ac_196577a_12
    from: 'Neutral'
    platform: state
    to: 'on'
   condition: []
  action:
  - device_id: fb6472741ff44afe8cc5d2f41771bc59
    domain: light
    entity_id: light.keuken_werkblad_1
    type: toggle
  - device_id: 16fadc5b0fb04986b302efb339cbd4c9
    domain: light
    entity_id: light.keuken_werkblad_2
    type: toggle
  - timeout: 00:00:05
    wait_template: '

**(And here some code to set the state of the switch back in to "neutral")**

  mode: single

Who can help me with this? Help is greatly appreciated.

1 Like