#RESTful sensor issue
1 messages · Page 1 of 1 (latest)
Sensor template:
- platform: rest
name: Smart svetlo
scan_interval: 1
resource: http://192.168.X.X/fresh.xml
value_template: >
{% for x in value_json["root"]["dout"] %}
{% if x["@id"] == "2" %}
{{x["@val"] | int}}
{% endif %}
{% endfor %}'
xml file:
<root xmlns="http://www.papouch.com/xml/quido/act">
<dout id="1" name="Hlavne svetlo" sts="0" val="0" pic="1" mde="1" pars="1;0;1250;-550;2"/>
<dout id="2" name="Smart svetlo 1" sts="0" val="0" pic="13" mde="0" pars="1;0;1250;-550;1"/>
<dout id="3" name="HA RaspberryPi" sts="0" val="0" pic="13" mde="0" pars="1;0;1250;-550;1"/>
</root>
remove the single quoate at the end of your rest
I can't believe I didn't notice that.... Thanks it works now, thanks.
I have another question regarding this xml. I want to create a switch that can turn on/off the light. I saw a few switches in community forum, but all of them were json files. How should the switch look like in this case?
Do you know how to do this from a command line? I have no clue how this/your switch works
Actually, I was trying to do it with curl command, but that didn't work.
so what does the manufacturer write on it? I have seen a few switches via MQTT so one can send json via rest to do things
I have no clue what your switch accepts
what is the brand?
isn't there a 'normal' intergation with HA?
to be honest, this is not really my thing as I donot know this method at all, I could only find this .. https://en.papouch.com/http-get-in-i-o-quido-modules-how-to-do-it-p4040/
Ok, so if anyone encounters the same problem, this is how I proceeded:
I created rest commands:
rest_command:
zapni_lampu:
url: 'http://192.168.X.X/set.xml?type=s&id=2'
method: GET
vypni_lampu:
url: 'http://192.168.X.X/set.xml?type=r&id=2'
method: GET
And then I created a light entity:
- platform: template
lights:
smart_svetlo:
friendly_name: Smart svetlo
value_template: "{{ states('sensor.smart_svetlo') == '1' }}"
turn_on:
service: rest_command.zapni_lampu
turn_off:
service: rest_command.vypni_lampu