Help with home assistant api call

I tried with auth disable as well.

Tried to send it as a cURL script from my xeoma server instead and it works fine.

But dont understand how to send header with the http request from xeoma.

Still have configuration error if one line.

As mentioned on some forum i uset the start a program in xeoma insted. Start program cURL with the header parameters. Not as good att plain http request i xemoma but good enought.

Hereā€™s the exact code I use on my Xeoma server.

#!/bin/bash

curl -X POST \\
    -H "Content-Type: application/json" \\
    -d '{"state": "on", "attributes": {"device_class": "motion", "friendly_name": "Driveway Cam 1 Motion"}}' \
    http://192.168.10.100:8123/api/states/binary_sensor.driveway_cam1_motion

I donā€™t use HTTP Auth on my system because itā€™s not Internet facing at all so I donā€™t have a need for Auth.

Scripts:
driveway_cam1_on.sh
driveway_cam1_off.sh

The only difference in the on/off is the state that I send in the curl command change the ā€œstateā€: ā€œonā€ section to either on or off.

I then use the Xeoma run script function or ā€œApplication Runnerā€. Thereā€™s 2 instances of Application runner. 1 for ā€œonā€ and 1 for ā€œoffā€.

I got it working at the command prompt

curl -X POST -H "x-ha-access: xxxxxxxxxxxxx" -H "Content-Type: application/json" -d '{"state": "on", "attributes": {"attribute_name": "attribute_value"}}' https://xxxxxx.duckdns.org:8123/api/states/climate.panasonic_aircon

and now I have it working using the rest_command too:

Configuration.yaml

rest_command:
  set_climate_to_on:
    method: POST
    url: 'https://xxxxxxxxxxxxx.duckdns.org:8123/api/states/climate.panasonic_aircon'
    headers:
      content-type: application/json
      password: xxxxxxxxxxxx
    payload: '{"state": "on", "attributes": {"current_temperature": {{ states.sensor.temperature_158d0001f52edb.state }}, "min_temp": 16, "max_temp": 30, "temperature": {{ states.sensor.climate_temperature.state }}, "target_temp_step": 1, "fan_mode": "{{ states.sensor.climate_temperature.state }}", "fan_list": ["low", "mid", "high", "auto"], "operation_mode": "off", "operation_list": ["off", "cool", "heat", "on"], "unit_of_measurement": "Ā°C", "friendly_name": "Heat Pump", "supported_features": 193}}'

sensor:
  - platform: template
    sensors:
      climate_temperature:
        value_template: "{{ states.climate.panasonic_aircon.attributes['temperature'] }}"
      climate_fan_mode:
        value_template: "{{ states.climate.panasonic_aircon.attributes['fan_mode'] }}"

Automation.yaml

- alias: "Set AC to ON"
  trigger:
  action:
    - service: rest_command.set_climate_to_on
2 Likes