Call a REST API when a Z-Wave Sensor reports

I’ve got an Aeon Power Meter (two actually, across different circuits in my house). I can see them both reporting “instantaneous power” as the values change - what’s the best way to “export” that data to a third party?

I’m trying now to “pull” the data using the HASS Rest API; but having no luck there, and I’m also not much for Polling if I don’t have to. Is there a way in HASS to detect the ZWave :“state change” and then make a REST call with the state values?

I guess it would depend on how the third party is capable of receiving data. Using an automation you could:

Right - my app has a REST API; but, when I need help with is getting the HASS scripting right so that when the ZWave sensor changes state (new value), HASS makes the correct call - detecting the state change and putting the values in the REST call

I don’t have all the details of your environment so this example is rudimentary and will require tailoring to suit your specific needs.

Begin by defining a rest_command that will post data to the 3rd party. Obviously you’ll have to modify it (minimally, the url and payload).

rest_command:
  report_power_level:
    url: https://third-party.com
    method: POST
    headers:
      accept: 'application/json, text/html'
    payload: '{"power_level": "{{ power }}"}}'
    content_type:  'application/json; charset=utf-8'

You should test it to ensure it works before proceeding to create an automation. Go to Home Assistant’s States page, select the rest_command you just created, enter some sample data like:
{"power_level": "your data goes here"}
and run it.

Create an automation that is triggered by the zwave sensor’s state-changes. Its action calls your rest_command and passes it the value of the sensor’s power-related attribute. I assume it’s in an attribute and not in the sensor’s state.

automation:
- alias: 'send to 3rd party'
  trigger:
    platform: state
    entity_id: sensor.some_zwave_sensor
  action:
    - service: rest_command.report_power_level
      data_template:
        power: "{{ trigger.to_state.attributes['your_power_attribute'] }}"

Like I said, this is a rough outline. If you provide me with specific details about your sensor and the 3rd party we can work together to customize this solution.

What do you have so far? I do something vaguely similar but with Slack; when I arrive at home/work I update my slack status and add an icon; when I am playing a game on my PlayStation I update my status with the game.

I use the RESTful command component (as shown above) to make the API call to Slack, so I would get that working first. You can then make an automation that is triggered when the state changes from your sensor. This is the bit I am not sure about as I don’t know how to trigger something more simple that I have done myself. Here is my automation;

- id: 'Set_Slack_Status_To_Current_Game'
  alias: 'Set Slack Status To Current Game'
  trigger:
    platform: state
    entity_id: media_player.playstation_4
    from: 'idle'
    to: 'playing'
  action:
    - service: rest_command.slack_status_set_from_ps4

And then the rest command;

slack_status_set_from_ps4:
  url: 'https://slack.com/api/users.profile.set'
  method: POST
  headers:
    content-type: application/json
    authorization: !secret slack_token 
  payload: '{"profile":{"first_name":"Luke","last_name":"Brunning","email":"[email protected]","status_text":"playing {{states.media_player.playstation_4.attributes.source}}","status_emoji":":joystick:"}}'

I would focus on getting the RESTful command working first; you can create that and then trigger it manually from the services section in HA and then at least you aren’t trying to get two things working at once.