Ok, but that’s not what it sounded like. It sure sounded like you were complaining that it wasn’t as simple as you would have liked.
I can certainly do that, but generally I don’t assume the person requesting help needs that level of hand holding.
No, it was not properly formatted. Notice the difference between your first post of the code and the second. Do they look the same to you? Can you tell if the code is indented properly in the first post? If you’re not sure what I’m talking about, see #11 in this topic.
In your second post I can see at least three basic problems. First, the indentation is wrong. Second you’re using the wrong kind of quote marks. They need to be the simple ' or " characters, not the fancy curly quote characters. Third you’re missing quotes at the ends of the templates. Also, you don’t show what that code is “under.” I.e, is it under sensor: or binary_sensor:? (It should be the latter.)
Try this:
- platform: template
sensors:
test_on:
friendly_name: "ON"
device_class: light
value_template: "{{ is_state('switch.h_hot_water_tank_switch', 'on') }}"
test_off:
friendly_name: "OFF"
device_class: light
value_template: "{{ is_state('switch.h_hot_water_tank_switch', 'off') }}"