Push/POST/send changes to Home Assistant?

Is there an easy way to send/post/push information to Home Assistant? I currently have a script running on my server that pings the phones of everyone in the house, and if there is a change in their status it will run a command.

At first I thought it would be a simple matter to use a curl command to change the state of a virtual switch, or update the value of a “sensor” in HA, but I haven’t been able to find a way to do that. Everything I have read on RESTfull switches and sensors is all about how to get information from them. Is there anyway for as switch or sensor to POST to HA?

You can use the HA Rest API to set states directly. Entities do not have to exist before you create them.

home-assistant.io/developers/re … tentity_id

Thank you! That was exactly what I was looking for!

I’m stuck again. Using the REST api has my presence detection working, and I have it triggering automations. Now I can’t figure out how to get a shell command to run for the action.

What do I need to do to get the command to run. This is what I have for the shell_command in my configuration.yaml

[code]shell_command:

  • me_home: curl -X GET http://admin:[REDACTED]@192.168.254.5/rest/vars/set/2/1/1
  • me_away: curl -X GET http://admin:[REDACTED]@192.168.254.5/rest/vars/set/2/1/0
    [/code]

And the automation:

[code]automation:

  • alias: ‘me Home’
    trigger:
    platform: state
    entity_id: sensor.me
    from: ‘Away’
    to: ‘Home’
    action:
    service: shell_command.me_home
  • alias: ‘me Away’
    trigger:
    platform: state
    entity_id: sensor.me
    from: ‘Home’
    to: ‘Away’
    action:
    service: shell_command.me_away
    [/code]

Make sure you keep an eye on the logs. It might be that there is some malformed configuration going on.

You can always try to trigger your shell commands manually by calling the service from the dev tools in the frontend.