Hey all, to start with a bit of back ground. I have a dumb TV in my living room, I have it plugged into a smart plug which is only there for energy monitoring. I also have a broadlink RF blaster programmed with a few of the TV remote buttons, and a short script for each of the programmed buttons to work, ie when I want to turn up the volume I call upon the relevant script. I setup a Threshold sensor helper to identify if the TV was on or not (reads 0 Watts when powered off, about 5W when first starting up and about 90-100W when operating). The threshold is 0.4-105W reads as the TV is on and everything else is off, its been working perfectly. I then used a template switch to make a UI switch that I can use from my app that gets feedback from the helper RE the tv state. The YAML from my config file relevant to the template switch is below, its fairly straight forward.
Onto the strangeness, when I use this switch; Home Assistant for unknown reasons also tries to turn on my Xbox. The Xbox integration works intermittently at best in my experience, and not at all for the last week or so at the time of this writing. When the integration isn’t working and I use the button an error message reading something to the effect of “xbox unavailable right now” and it details the specific service it is trying to call which turns on the xbox. If the integration is working at the time of triggering the switch, it turns the xbox on if it isn’t already on (if it is on already, a “I can’t do that right now” message comes up on the xbox.
switch:
- platform: template
switches:
living_room_tv:
value_template: "{{ is_state('binary_sensor.living_room_tv_power_state', 'on') }}"
turn_on:
service: script.living_room_power
target:
entity_id: binary_sensor.living_room_tv_power_state
turn_off:
service: script.living_room_power
target:
entity_id: binary_sensor.living_room_tv_power_state
icon_template: >-
{% if is_state('binary_sensor.living_room_tv_power_state', 'on') %}
mdi:television-classic
{% else %}
mdi:television-classic-off
{% endif %}
And next is the YAML of the script for the broadlink device being called
alias: Living Room TV Power
sequence:
- type: toggle
device_id: 4abbb3a42e0094e19b6a497bf20c1459
entity_id: remote.living_room_tv_remote_remote
domain: remote
enabled: false
- service: remote.send_command
data:
device: LivingRoom_TV
command: Power
hold_secs: 0.3
num_repeats: 1
delay_secs: 0.4
target:
entity_id: remote.living_room_tv_remote_remote
area_id: living_room
mode: single
icon: mdi:television-classic
Having one button turn on the xbox and the tv isn’t entirely undesirable as it is the device we use for most of our entertainment on that TV anyway, but I would rather set that up separately perhaps in a scene or the like.
EDIT: Update, I haven’t done anything, but I just used it and no message popped up about being unable to reach the Xbox, I think its more to do with how broken that integration is than my switch not calling the service.