Help with REST Command & Automation

Hi all, hoping someone can help with this issue.

I have setup a rest.yaml file and have various commands within this file. All work perfectly and use a number in automations to trigger them. However one new command entered is not working when used with HA automations. The REST entry is below:

ensuite_tv_on:
  url: "http://192.168.1.137/api/command/rs232pass/5/1"
  method: post
  content_type: "application/json"
  payload: '{"rs232data":"A0F055FFAE51"}'
  headers:
    Accept-Charset: "utf-8"

If I use Developer Tools and action this it works perfectly. However when I include this within an automation it does not action despite HA logging it has actioned the automation. Here’s the actual automation which triggers the REST command above:

alias: Ensuite TV On
description: ""
triggers:
  - domain: edinplus
    device_id: 2c654a96d78374f1de7cf4aa29a47c13
    type: Button 5 Short-press
    trigger: device
conditions: []
actions:
  - action: rest_command.ensuite_tv_on
    data: {}
mode: single

If I look at the trace for this automation it shows as triggered and the action performed but unfortunately it doesn’t work when used through the automation.

Can anyone helps diagnose what’s causing this? Many thanks for any help.

Have a look at the full trace: three dots top-right, Download Trace. Paste it here if it doesn’t answer the question for you.

Thanks for the reply. Here’s the full trace:

{
  "trace": {
    "last_step": "action/0",
    "run_id": "66eb860d27971e75cf095844c31c8267",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2025-07-10T06:23:11.627997+00:00",
      "finish": "2025-07-10T06:23:11.653914+00:00"
    },
    "domain": "automation",
    "item_id": "1752066511091",
    "trigger": "event 'edinplus_event'",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2025-07-10T06:23:11.628307+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.ensuite_tv_on",
              "state": "on",
              "attributes": {
                "id": "1752066511091",
                "last_triggered": "2025-07-09T20:09:52.416645+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Ensuite TV On"
              },
              "last_changed": "2025-07-09T13:14:34.988071+00:00",
              "last_reported": "2025-07-09T20:09:52.437696+00:00",
              "last_updated": "2025-07-09T20:09:52.437696+00:00",
              "context": {
                "id": "01JZRCY510XKXEFSYB77AQ3ZZQ",
                "parent_id": "01JZRCY510ZCHGW70QJJ793Y9G",
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "device",
              "event": {
                "event_type": "edinplus_event",
                "data": {
                  "device_id": "2c654a96d78374f1de7cf4aa29a47c13",
                  "type": "Button 5 Short-press"
                },
                "origin": "LOCAL",
                "time_fired": "2025-07-10T06:23:11.627627+00:00",
                "context": {
                  "id": "01JZSG15RBDX84G1CFK21YKRW8",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "description": "event 'edinplus_event'"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2025-07-10T06:23:11.628911+00:00",
          "changed_variables": {
            "context": {
              "id": "01JZSG15RBF9NK16Z32XXBGZ1N",
              "parent_id": "01JZSG15RBDX84G1CFK21YKRW8",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "rest_command",
              "service": "ensuite_tv_on",
              "service_data": {},
              "target": {}
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "id": "1752066511091",
      "alias": "Ensuite TV On",
      "description": "",
      "triggers": [
        {
          "domain": "edinplus",
          "device_id": "2c654a96d78374f1de7cf4aa29a47c13",
          "type": "Button 5 Short-press",
          "trigger": "device"
        }
      ],
      "conditions": [],
      "actions": [
        {
          "action": "rest_command.ensuite_tv_on"
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01JZSG15RBF9NK16Z32XXBGZ1N",
      "parent_id": "01JZSG15RBDX84G1CFK21YKRW8",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Ensuite TV On",
      "message": "triggered by event 'edinplus_event'",
      "source": "event 'edinplus_event'",
      "entity_id": "automation.ensuite_tv_on",
      "context_id": "01JZSG15RBF9NK16Z32XXBGZ1N",
      "domain": "automation",
      "when": 1752128591.6284816
    }
  ]
}

No obvious issues there. Does the API return anything? You could try:

actions:
  - action: rest_command.ensuite_tv_on
    response_variable: my_response
    data: {}
  - action: system_log.write
    data:
      message: "{{ my_response|to_json }}"
      level: info

and see if there’s anything useful in the log. (EDIT: incorrect title removed)

Thank you again for the reply.

The log shows the following so something isn’t quite right but odd that it works if executed through Developer Tools, Actions:

Logger: homeassistant.components.automation.ensuite_tv_on
Source: components/automation/init.py:738
integration: Automation (documentation, issues)
First occurred: 12:53:07 (1 occurrence)
Last logged: 12:53:07

Error while executing automation automation.ensuite_tv_on: extra keys not allowed @ data[‘title’]

No, that was my fault for not reading the docs carefully enough. system_log.write doesn’t have a title. Sorry.

actions:
  - action: rest_command.ensuite_tv_on
    response_variable: my_response
    data: {}
  - action: system_log.write
    data:
      message: "{{ my_response|to_json }}"
      level: info

No problem.

Having changed that element the logs show nothing for this automation when actioned. However weirdly it’s now working :roll_eyes:.

Thanks for your responses and help. Very odd to suddenly start working and without a restart or changing anything material except adding the logging. Have now removed the logging and still working. :thinking:

1 Like

It’s the red bit.

1 Like