dragg
December 31, 2021, 11:20am
1
I am trying to upload my energy consumption data to PVOutput using this command:
curl -d "d=$(date +'%Y%m%d')" -d "t=$(date +'%H:%M')" -d "v3=insert sensor value here" -H "X-Pvoutput-Apikey:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -H "X-Pvoutput-SystemId:xxxx" https://pvoutput.org/service/r2/addstatus.jsp
If i substitute a number in the field ‘v3’ the command works but i cant figure out how to put a sensor value in there.
Sorry if the question is dumb but I’m new to all this
Thanks
Try shell command :
shell_command:
publish_sensor_state: >-
curl -d "d=$(date +'%Y%m%d')" -d "t=$(date +'%H:%M')" -d "v3={{ states('sensor.entity_id_here') }}" -H "X-Pvoutput-Apikey:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -H "X-Pvoutput-SystemId:xxxx" https://pvoutput.org/service/r2/addstatus.jsp
You can then use it by calling the service shell_command.publish_sensor_state
.
dragg
December 31, 2021, 7:14pm
3
If i run the command via the service call i get no feedback and no data gets uploaded,
if i run it in the terminal i get an error stating missing energy values and still no data gets uploaded
Is uses a jinja2
template , so you can’t just run the command in the terminal. It needs to be done within a shell_command
in Home Assistant.
Maybe shell_command
does not like $()
. It is not possible to use pipes when using templates in shell_command
for example.
Try this:
shell_command:
publish_sensor_state: >-
curl -d "d={{ now().strftime('%Y%m%d') }}" -d "t={{ now().strftime('%H:%M') }}" -d "v3={{ states('sensor.entity_id_here') }}" -H "X-Pvoutput-Apikey:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -H "X-Pvoutput-SystemId:xxxx" https://pvoutput.org/service/r2/addstatus.jsp