How to arm a device using a scene

Hi all!

I have created these two scenes, but nothing happens when I run these scenes.
What I wa’na do is to arm or disarm a door sensor.

scene:
  - name: arm_doors_and_windows
    entities:
      binary_sensor.dorr_balkongen_34:
        state: off
        device_armed: True
  - name: disarm_doors_and_windows
    entities:
      binary_sensor.dorr_balkongen_34:
        state: off
        device_armed: False  

This is indeed a very basic scene, but I just can’t get it to work.

  • Spelling is correct.
  • Indentering is correct

Any ideas would be very welcome.

What is the definition of your binary sensors?
Normally the state of a sensor is determined by it’s definition and not subject to being set by an automation.

I’m not quite sure what you mean by “the definition of your binary sensors”.

I just want to change the attribute device_armed to either True or False.

EDIT: In a previous version, I begun saying “I’m now quite sure”, an expression quite contrary to what I actually ment. Sorry for that, @treno and all other readers.

Sensors are typically set up to GATHER information from a source, not to SEND information to a source.
There are a myriad of sensor platforms, and seeing how your sensor is defined in configuration.yaml MIGHT let me help you resolve your problem.

Thanks, This centence: “Sensors are typically set up to GATHER information from a source, not to SEND information to a source.” made me look a bit future down in the States-list.

So therefore I changed
binary_sensor.dorr_balkongen_34
to
switch.dorr_balkongen_34
in my scenes, but still no luck.

Here are my scenes now:

scene:
  - name: arm_doors_and_windows
    entities:
      switch.dorr_balkongen_34:
        state: off
        device_armed: True
  - name: disarm_doors_and_windows
    entities:
      switch.dorr_balkongen_34:
        state: off
        device_armed: False  

Any ideas would be very welcome.
And thanks for your help so far!

I copied your scene to my test system. When you try to assign the attribute “device_armed” the scene fails, and a system error is generated:

ERROR (MainThread) [homeassistant.core] Invalid service data for switch.turn_on: extra keys not allowed @ data[‘device_armed’]. Got True

But when you remove that device_armed code, the scene is successful.
I think what this means is you can’t just assign values to random attributes that don’t already exist on the object you are manipulating.

In this case, the object switch.dorr_balkongen_34 does not have an attribute device_armed, so you can’t set it.

Hello again @treno and thanks for your dedication! It’s appreciated

.

I actually copied the attribute device_armed straight from the States list as seen in the screenshot above.

You’re right about that the scene runs if i just change the state or if I do something else.

My problem seems to be how to change the attribute device_armed.I guess my question must be “How to change an existing attribute in a switch”, so I changed the subject of this topic.

Ok, this was much easier than I thought.

To arm a device, in my case switch.dorr_balkongen_34 just set the state to on, and to disarm, set the state to off. No need to alter attributes.

Here’s the working scenes.

scene:

# Arm that door
  - name: arm_doors_and_windows
    entities:
      switch.dorr_balkongen_34:
        state: on

# Disarm that door
  - name: disarm_doors_and_windows
    entities:
      switch.dorr_balkongen_34:
        state: off

Once again, thanks a lot @treno for all your help!