Inverting meaning of a switch

HA has discovered a switch entity for a tasmotized device but I would like to invert it’s meaning in Lovelace. In other words, when the switch toggle displayed in Lovelace is on, I want the real one to be off and vice versa.

How do I make this happen?


  - platform: template
        value_template: "{{ is_state('switch.tasmota', 'off') }}"
          service: switch.turn_off
          entity_id: switch.tasmota
          service: switch.turn_on
          entity_id: switch.tasmota

And use switch.something on your lovelace interface.

The configuration checker does not like in configuration.yaml

Should I have put it somewhere else?


What does the config checker say?

It’s looking mangled because I did it through the GUI rather than through a SSH shell

 Invalid config for [switch.template]: invalid slug switch.study_overheads_inverted (try switch_study_overheads_inverted) for dictionary value @ data['switches']. Got OrderedDict([('switch.study_overheads_inverted', OrderedDict([('value_template', "{{ is_state('switch.study_overheads', 'off') }}"), ('turn_on', OrderedDict([('service', 'switch.turn_off'), ('entity_id', 'switch.study_overheads')])), ('turn_off', OrderedDict([('service', 'switch.turn_on'), ('entity_id', 'switch.study_overheads')]))]))]). (See ?, line ?). 

study_overheads_inverted is the newly created version of the existing study_overheads switch entity

You’ve put a dot in the name of the switch (where you replaced the word ‘something’), remove the dot.

1 Like

That is embarrasing :blush:

1 Like

It is working after restarting the HA server. Was there a less disruptive way of having it pick up the new config?


Go to the server control tab in GUI, and reload template switches.

Thanks, @KTibow

I’m coming up the learning curve slowly but surely thanks to people here!

1 Like

or… navigate to the URL of your tasmota device on your LAN (eg: 10.0.0.nn), and re-configure the device in the tasmota menu, Menu / Confiure Module… Tasmota has “i” inverse modes for switches/relays etc. No mod to HA required.

I used a Gosund SW6 in a 3-way circuit by following this Tasmota template and it worked.

Some day, I will have the courage to play with inverse modes!