Script Issues - Condition Changes (VeSync & Samsung)

I am attempting to create a script that will turn off levels of the house with a click. Right now I have it activating a Lutron scene (shutting down lights and Sonos) and then changing the condition of VeSync smart plugs and a Samsung TV. The Lutron part goes great, the VeSync and Samsung pieces do not.

I’ve thrown in the towel with Samsung TV integration because it’s so touchy - I can get it to power off, pause/play, etc but I don’t expect more in terms of automation. The VeSync part is what’s bugging me…

If I change the entity condition with the lovelace switch it works like a charm. Changing the condition state to off via the Script doesn’t work. I did a little troubleshooting and found that manually changing the condition via the State tab in the Dev pane fakes HASS into thinking it’s in the wrong state. For example, if I change the entity condition to on via the lovelace gui, it turns on the plug. Then, if I go into the Dev>State tab and change the condition to off, nothing happens BUT HASS now thinks the plug is off.

What did I break??

Also, if anyone has thoughts on the Samsung piece (does the same thing as VeSync), I be happy to hear them but don’t expect too much.

You broke nothing. This is how it has always worked. The next state update will overwrite your manual change.

Changing the state manually will simply update everything in home assistant. It will trigger automations monitoring the entity id, lovelace will update, etc etc etc. But it will not communicate anything with the device. As far as Home Assistant knows, the switch is in the ‘off’ state until a new update. Most switches don’t send updates unless they change state, so Home Assistant will store the off state forever until you change it back, or it gets an update (go toggle the switch manually). Well, maybe not forever. Depending on which database you use, it should reset on reboot maybe.

Thank you! Glad to know it was behaving as expected.

Any recommendations on how to do what I’m trying to do with the script? Would a a call out to the API be a better course of action?

I don’t have any Lutron, VeSync or Samsungs around. But I would just create groups if all you want to do is turn these things off.

group:
  kitchen:
    name: Kitchen
    entities:
      - switch.kitchen_pin_3
      - light.light1
      - switch.toaster
  living_room:
    name: Living Room
    entities:
      - light.living_room_light
      - media_player.samsung_tv
      - switch.random_switch
service: homeassistant.turn_off
entity_id: group.living_room

The homeassistant.turn_on/off command is very versatile. It will attempt to turn off any and all entities you pass in that can be turned off. I think it will skip things that don’t have the attribute you’re attempting, but could be wrong.

Scenes are useful when you want to turn a bunch of things to a specific state. Sure, off is a state, but creating a scene for that seems like overkill.

1 Like

Good point - I’ll give this a whirl. Thanks for the tip!