Hi, I am struggling with creating a switch for one button LG TV - “Turn On”, “Turn Off” control
I need to use wake on lan automation to turn the TV on and this works
- alias: "turn_on_lg_loznice_patro2"
trigger:
- platform: webostv.turn_on
entity_id: media_player.lg_webos_smart_tv
action:
- service: wake_on_lan.send_magic_packet
data:
mac: 20:17:42:E0:xx:xx
however, the following code for the switch returns a number of errors, which I did solve, but I cannot find a resolution for this one: Invalid config for [switch.template]: not a valid value for dictionary value @ data[‘switches’][‘tv_loznice_patro’][‘turn_off’][0][‘target’][‘entity_id’]. Got None. (See ?, line ?).
I know, there is a problem between the chair and keyboard, but how to fix this?
- platform: template
switches:
tv_loznice_patro:
value_template: "{{ is_state('automation.turn_on_lg_loznice_patro2', 'on') }}"
turn_on:
service: switch.turn_on
target:
entity_id: automation.turn_on_lg_loznice_patro2
turn_off:
service: switch.turn_off
target:
entity_id: turn_on_lg_loznice_patro2
tom_l
June 17, 2023, 6:14am
2
You forgot the domain of the entity id:
turn_off:
service: switch.turn_off
target:
entity_id: automation.turn_on_lg_loznice_patro2
However you can’t use the switch turn on or off service with an automation entity. Only a switch entity.
Use this instead:
Thank you, a lot @tom_I !
This works well now using just one chip button:
- platform: wake_on_lan
name: "lg_tv_loznice_patro"
mac: 20:17:42:E0
turn_off:
service: media_player.turn_off
target:
entity_id: media_player.tv_patro_loznice
What do I need to set up to turn on / off directly when I press the button without the need to select in an additional window?
tom_l
June 19, 2023, 1:41pm
4
Reserve your TV a static ip address. Fill that out in the host:
option for the WoL switch.
The switch will then have state feedback (using ping/ICMP). This will enable Home Assistant to show the switch as one button.
At the moment it has no idea if your TV is on or off so has to show two buttons, one for on and one for off, so you can choose the correct one.
Thank you @tom_I a lot!
Using the mushroom entity card, I have to select toggle, and it works (just one downside is that there is a delay in icon change, so need to wait cca 20 seconds to see the change)…
tom_l
June 19, 2023, 4:30pm
6
There’s not much you can do about the turn on time but for the turn off time you can try this:
- platform: wake_on_lan
name: "lg_tv_loznice_patro"
mac: 20:17:42:E0
turn_off:
- service: media_player.turn_off
target:
entity_id: media_player.tv_patro_loznice
- delay: 3
- service: homeassistant.update_entity
target:
entity_id: switch.lg_tv_loznice_patro
Experiment with the delay to get the fastest reliable update time when you turn off the switch.