core icon indicating copy to clipboard operation
core copied to clipboard

Rest command doesn't work when executed by automation

Open knilem opened this issue 9 months ago • 3 comments

The problem

I’m trying to integrate my home heat pump into HA. I’m having problem with automation running rest_command, to set room temperature in heat pump controller. When I run rest_command with Developer tools → Actions the command works, but when the command is run by automation, heat pump will not change its temperature.

Rest command:

rest_command: heat_pump_set_temperature: url: "http://192.168.1.234/d13output.cgi" method: POST payload: "id=MV1&MV1_Thi=220" content_type: "application/x-www-form-urlencoded"

I hardcoded to send command for 22°C while debugging.

The trace for this automation gives no error and shows that the rest_command was performed. The debug log for rest_command shows that commands were successful, but heat pump’s settings doesn’t change when the rest_command is run by automation and it works when run by Developer tools → Actions.

What version of Home Assistant Core has the issue?

core-2025.2.4

What was the last working version of Home Assistant Core?

core-2025.2.4

What type of installation are you running?

Home Assistant Container

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

rest_command:
  heat_pump_set_temperature:
    url: "http://192.168.1.234/d13output.cgi"
    method: POST
    payload: "id=MV1&MV1_Thi=220"
    content_type: "application/x-www-form-urlencoded"

automation:
    - id: set_heat_pump_temperature
      alias: Set Heat Pump Temperature
      description: Adjust temperature via input_number
      triggers:
        - trigger: state
          entity_id: input_number.heat_pump_temperature
      actions:
        - action: rest_command.heat_pump_set_temperature
        - delay: 0:20
      mode: single

Anything in the logs that might be useful for us?

2025-02-28 09:53:09.690 INFO (MainThread) [homeassistant.components.automation.set_heat_pump_temperature] Set Heat Pump Temperature: Running automation actions
2025-02-28 09:53:09.691 INFO (MainThread) [homeassistant.components.automation.set_heat_pump_temperature] Set Heat Pump Temperature: Executing step call service
2025-02-28 09:53:09.727 DEBUG (MainThread) [homeassistant.components.rest_command] Success. Url: http://192.168.1.234/d13output.cgi. Status code: 200. Payload: b'id=MV1&MV1_Thi=220'
2025-02-28 09:53:14.083 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Running websocket_api script
2025-02-28 09:53:14.083 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Executing step call service
2025-02-28 09:53:14.119 DEBUG (MainThread) [homeassistant.components.rest_command] Success. Url: http://192.168.1.234/d13output.cgi. Status code: 200. Payload: b'id=MV1&MV1_Thi=220'
2025-02-28 09:53:14.136 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Stop script sequence: done

Additional information

I recorded internet traffic with wireshark, but still don't understand why the same command works when run with debug tools and doesn't when run with automation. This is the trafic when the command was successful: https://imgur.com/a/V42E4oy, and this is when run with automation: https://imgur.com/a/o7hBwMW

knilem avatar Feb 28 '25 09:02 knilem

Hey there @jpbede, mind taking a look at this issue as it has been labeled with an integration (rest_command) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of rest_command can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign rest_command Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


rest_command documentation rest_command source (message by IssueLinks)

home-assistant[bot] avatar Apr 20 '25 10:04 home-assistant[bot]

When the action works via the developer tools, then they also work via a automation. As you see in your provided log and Wireshark dump you see the HTTP calls getting triggered but your device does not reply. Maybe your device has some sort of rate limiting or it doesn't allow a follow up HTTP request while the device is still in progress of the first call.

jpbede avatar Apr 21 '25 09:04 jpbede

Hi, I have similar issue, my put commands works with development tool no problem, however in automation I always receive timeout - would like to ask if there could be any difference when running the restful call inside an automation? My call is very simple with no payload.

maisun avatar May 11 '25 10:05 maisun

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.