kc1950
November 27, 2020, 3:07pm
1
I want every 15 minutes the value of a sensor export to an external website.
That external website (like pvouput.org ) can be called as follows:
http://192.168.178.31/upload/data.php?object_id=5970&api_key=123456789abcd&var=ehh&moment=1605862431&value=24168.7
where object_id and api_key are identifiers given by the site
var is the code of the variable where the data must go
moment is the time in utc-integer
value is the state
Therefore I have defined a notification:
notify:
- name: upload_emo
platform: rest
resource: "http://192.168.178.31/upload/data.php?object_id=5970&api_key=123456789abcd"
method: GET
and an automation:
automation:
- alias: upload_data_to_emo
initial_state: 'on'
trigger:
- platform: time_pattern
minutes: "/15"
action:
- service: notify.upload_emo
data_template:
message: "Test upload"
moment: "{{ now().timestamp() | int }}"
var: "eh"
value: "{{ states.sensor.luxtronik_energieverbruik.state }}¨
But when I run the configuration I get a error message in the log:
“voluptuous.error.MultipleInvalid: extra keys not allowed @ data[‘moment’]”
What am I doing wrong?
Thank you in advance.
tom_l
November 27, 2020, 4:55pm
2
I’ve never used it but from looking at the docs I think you have to supply a dictionary of the extra parameters you want to send in the notification options: https://www.home-assistant.io/integrations/notify.rest/#data
notify:
- name: upload_emo
platform: rest
resource: "http://192.168.178.31/upload/data.php?object_id=5970&api_key=123456789abcd"
method: GET
data:
message:
moment:
var:
value:
Also if you are running version 0.115 or greater you should use just data:
instead of data_template:
in your automation.
kc1950
November 27, 2020, 10:19pm
3
I changed my configuration as you suggested:
notify:
- name: upload_emo
platform: rest
resource: "http://192.168.178.31/upload/data.php?object_id=5970&api_key=123456789abcd"
method: GET
data:
message:
moment:
var:
value:
automation:
- alias: upload_data_to_emo
initial_state: 'on'
trigger:
- platform: time_pattern
minutes: "/15"
action:
- service: notify.upload_emo
data:
message: "Upload test"
moment: "{{ now().timestamp() | int }}"
var: "eh"
value: "{{states.luxtronik_energieverbruik.state}}"
I still get the same error:
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['moment']
tom_l
November 27, 2020, 10:52pm
4
As I said:
tom_l:
I’ve never used it
So not really sure, just gave it my best guess.