Run python script as an action

Hi! I’m a beginner to home assistant but have been able to get a few things set up. I want to have a door sensor (Monoprice Z Wave+) trigger my Kevo to lock the door when it closes. I have the sensor working for my kitchen lights at the moment to prove to my self that I have them integrated correctly. I’m using a set of python scripts created by Bahnburner to control my Kevo from HA. What I can’t figure out is out to run lock-door.py script as an action.

#Kevo door component
switch:
  - platform: command_line
    scan_interval: 30
    switches:
      door_side:
        command_on: "python3 /home/homeassistant/.homeassistant/kevo/lock-door.py"
        command_off: "python3 /home/homeassistant/.homeassistant/kevo/unlock-door.py"
        command_state: "python3 /home/homeassistant/.homeassistant/kevo/status-door.py"
        value_template: >
          {% if value == "Locked" %}
            true
          {% elif value == "Unlocked" %}
            false
          {% else %}
          {% endif %}

automation:
  - alias: Lock Kevo
    trigger:
      platform: numeric_state
      entity_id: sensor.hank_unknown_type0201_id0008_access_control
      above: 22
    action:
      #??? What goes here ???

You actually don’t need to anymore. Gaggle331 created an unofficial component to control Kevo locks using the PyKevoControl library. Once it’s set up, your locks will show up as actual locks in HASS rather than switches.

You can pick up on the discussion here.

That being said, to directly answer your question, it would be

service: switch.turn_on
entity_id: switch.door_side

Thank you so much! I don’t know how I didn’t see that on that same thread. I guess I didn’t realize the difference between a new component and the scripts that were initially mentioned in that thread.

No worries. Glad I could help.