Hello i am a new user on home assistant.
I want to read from my Rademacher Umweltsensor the variable Rain (Regen erkannt).
the call is
http://192.168.2.2/deviceajax.do?meter=1010031
The Response is
{ “response” : “get_meter_data”, “status” : “ok”, “data”:[{“Lichtwert”:“41000 lx”},{“Windgeschw.”:“4 m/s”},{“Temperatur”:“7.5 °C”},{“Regen”:“Nicht erkannt”},{“Sonnenhöhe”:“19°”},{“Sonnenrichtung”:“Süd-Westen (237°)”},{“Aktualisiert”:“08.03.19 - 16:01”}] }
i need the variable Regen: erkannt or nicht erkannt as a sensor.
How can i with this sensor a automation example a
Lawn mower stops at rain.
Sorry for my bad english !
Your English is fine.
Something like this may work.
Hallo bosborne,
Can you give me an example for my scenario.
Thanx
I am very new here, but let me try. How about this?
Example configuration.yaml entry
sensor:
- platform: rest
resource: http://192.168.2.2/deviceajax.do?meter=1010031
name: Erkannt
value_template: '{ value_json.erkannt}'
eXtatic
(Dominik 🇩🇪)
March 8, 2019, 10:24pm
5
Hi, I think the json template is not working like that, try:
value_template: '{ value_json.data[3].Regen}'
It will return the value of the key „Regen“ which is either „Erkannt“ or „Nicht erkannt“. This sensor can then be used as a trigger for automations.
EDIT:
Changed [0] to [3], thanks for the hint @anon34565116
Also added the snipped from the HA dev-template
HA dev-template:
{% set value_json = {
"response" : "get_meter_data",
"status" : "ok",
"data":[
{"Lichtwert":"41000 lx"},
{"Windgeschw.":"4 m/s"},
{"Temperatur":"7.5 °C"},
{"Regen":"Nicht erkannt"},
{"Sonnenhöhe":"19°"},
{"Sonnenrichtung":"Süd-Westen (237°)"},
{"Aktualisiert":"08.03.19 - 16:01"}
]
} %}
value_templates
Regen1: {{ value_json.data[3].Regen }}
Regen2: {{ value_json.data[3].Regen == "Erkannt" }}
Regen3: {{ value_json.data[3].Regen == "Nicht erkannt" }}
sensor output
Regen1: Nicht erkannt
Regen2: False
Regen3: True
Thanks for the correction.
I am not certain about the [0] part though. You can try & see which works.
When there are really only 2 distinct values (“Erkannt” vs “Nicht erkannt”) you may want to look at a binary rest sensor instead. Its value_template
would be similar to the above:
value_template: “{{ value_json.data[3].Regen == ‘Erkannt’ }}”
i have in the configuration
rest_command:
robby_feierabend:
url: ‘http://192.168.2.252/xml?cmd=mode&mode=eod&user=banane&pass=affe ’
robby_auto:
url: ‘http://192.168.2.252/xml?cmd=mode&mode=auto&user=banane&pass=affe ’
at check the config i have errors
Only with one rest_comand it works
the automation is :
alias: robby bei regen heim
trigger:
platform: state
entity_id: binary_sensor.regen
from: ‘off’
to: ‘on’
action:
- service: rest_command.robby_feierabend
please help
eXtatic
(Dominik 🇩🇪)
March 9, 2019, 7:31pm
10
Please provide formatted yaml, I think you need to use - if you defined multiple rest commands.
rest_command:
robby_feierabend:
url: ‘http://192.168.2.252/xml?cmd=mode&mode=eod&user=banane&pass=affe’
robby_auto:
url: ‘http://192.168.2.252/xml?cmd=mode&mode=auto&user=banane&pass=affe’
EDIT: Seems dashes are not necessary, maybe just indentation issue?
with - i have this error message
Invalid config for [rest_command]: expected dictionary for dictionary value @ data[‘rest_command’]. Got [OrderedDict([(‘robby_feierabend’, None), (‘url’, ‘http://192.168.2.252/xml?cmd=mode&mode=eod&user=tom&pass=rrrr ’)]), OrderedDict([(‘robby_auto’, None), (‘url’, ‘http://192.168.2.252/xml?cmd=mode&mode=auto&user=tom&pass=rrrr ’)])]. (See /config/configuration.yaml, line 178). Please check the docs at https://home-assistant.io/components/rest_command/
eXtatic
(Dominik 🇩🇪)
March 11, 2019, 6:17am
12
Can you provide your formatted config? =>
The Problem is solved.
The formatting was the Problem.
Thanx