Send RPC (?) ON and AUTO OFF command to Shelly switch from home assistant

Hi there. I want to implement a safe way to turn on the switches controlling my heating floor valves so insted of sending th turno and turn off commands separately, send an ON and AUTO_OFF order at the same time. If the HA connection blackout, the valve still would be closed.

I read kind of a code in apost biut don’t know how to implement it on an automation YAML code. I found this code from a Jan-Helge Karlsson:

The good syntax is now (without spaces)

http:// 192.168.xxx.xxx / rpc / Switch.SetConfig?id=0&config={“auto_off_delay”:3600}

Where should I put this code? In an action? Which action?

Thank you very much.

You could put in configuration.yaml …

# rest command to set auto_off_delay
rest_command:
  your_shelly_set_auto_off_delay:
    url: "http:///ip_of_your_device/rpc"
    method: POST
    headers:
      Content-Type: "application/json"
    payload: '{"id":1,"method":"Switch.SetConfig","params":{"id":0, "config":{"auto_off_delay": {{ delay }}}}}'

And then use this action:

action: rest_command.your_shelly_set_auto_off_delay
data:
  delay: 3600

To get the current auto off setting from Shelly, create a sensor

#read auto_off_delay from shelly
sensor:
  - platform: rest
    name: Shelly auto off delay
    resource: http://ip_of_your_device/rpc/Switch.GetConfig?id=0
    value_template: "{{ value_json.auto_off_delay }}"

Documentation:

Thank you but I can`t make it work. Sensor does not show.

  1. Do you have restarted HA?
  2. Is the IP correct?
  3. Can you show the related part from configuration.yaml?