Passing sensor value to shell command

Hi!

I am using Pushovers Glances API to update a complication on my Apple Watch with a sensor value.

It works so far that if I run a curl POST with a fixed value from the command line of the raspberry pi it updates the complication just fine. And the trigger (every 30 minutes) triggers the script as well. It just doesn’t send a value.

In my Configuration.yaml I write:

shell_command:
  pushmoisture: 'curl --data "token=mytoken&user=myuser&percent={{ states.sensor.tomat.attributes.moisture }}"      https://api.pushover.net/1/glances.json'

The sensor I am trying to get at is usually called “sensor.tomat_moisture” (which I use for other automations) but I got this way of calling it from reading the docs and some posts here. I’ve seen another way to call that value: states.sensor.tomat.attributes[”moisture”]
but the one I went with seemed to be in use more often.

From the logs I found that the value that is actually sent is: “None”. So everything is firing and authenticating, but the actual value isn’t passed on.

What did I miss?

First of all you can try out templates in the template designer in the dev tools. Navigation tab at the bottom one of the symbols. Secondly why aren’t you using it the same way you do in automations? Like

  pushmoisture: 'curl --data "token=mytoken&user=myuser&percent={{ states.sensor.tomat_moisture.state }}"

~Cheers

1 Like

Thank you!

That was it!

I think the examples I was reading had sensors with multiple attribues, which my sensor also have, but HA recognises it as separate sensors, so…

But is there a document for the naming conventions? I am fairly well versed in scripting languages (just not this one) but it was hard to find out how to write the exchangeable marker for this.