Advice for automatically turning off smart switch, based upon Firestick output (Home Assistant)

Morning all.

I have what should be a fairly basic thing to set up but I cannot get my head round the best way to do it.

In Home Assistant, I have my Firestick connected as an entity and it outputs six outputs (playing, paused, idle, sleep, off and unavailable).

I also have my TV connected to a smart switch.

What I want is the following:

  1. If the Firestick outputs "playing", "pause" or "idle", turn the smart switch on.
  2. If the Firestick outputs anything else, for one minute, turn off the smart switch.

If I did not need the one minute pause, it would be a simple case (I think) of just outputting the change of state to a switch and sending the first three outputs to trigger the smart switch on and then having an "otherwise" option to trigger the smart switch off.

Any advice for putting together and elegant solution would be much appreciated.

I don't know if a firestick sends it's status automatically or if you have to interrogate it?

Regarding turning off, there is a trigger node which you can set up to send nothing until 1 minute has elapsed and then send "OFF".
Probably you need to tick "Extend delay if new message arrives".

Something like this might work?

1 Like

Thank you so much - really clever.

I shall give that a whirl.

One other quick thing, while I think about it.

When I am using the firestick, it will constantly switch between "paused" and "playing" while I am watching things on youtube.

Is it bad/inefficient to be constantly sending a "turn on" signal to the smart switch, even thought it is already on?

I wasn't sure if I needed another node (current state) to only send pass on the signal if the current state of the switch was off.

That's a good question.
I guess that nothing happens if the relay is already closed and you send another ON signal.
It feels wrong though.

Luckily, it is easy to prevent repeated messages to the switch with a filter node. It's default setting is "block messages unless value changes".

And note that you don't actually need to set msg.reset, the trigger can be set to reset if msg.payload = "ON"

1 Like

Your are a genius!!!

Worked flawlessly - thank you.

There were a couple of nodes you recommended, that I had never considered using before, but certainly now will.

Really appreciate your help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.