Xml in domoticz?
Moderators: leecollings, remb0
-
edwin1234
- Posts: 330
- Joined: Sunday 09 October 2016 20:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Nederland
- Contact:
Xml in domoticz?
How can i get the info out of an xml file and use it in domoticz?
So there be devices with the given info from the xml file in domoticz.
Example : CloseInBoiler status=on usage=0W
See my xml file:
<PlugwiseSource Version="1.0">
<Appliances>
<Appliance Id="13" Name="CloseInBoiler" Type="water_heater_vessel" PowerUsage="0,0000" TotalUsage="927,83" PowerState="on" Module="14" Image="/sysimg/32/water_heater_vessel_on.png"/>
<Appliance Id="9" Name="CV-ketel" Type="heater_central" PowerUsage="69,0000" TotalUsage="394,95" PowerState="on" Module="10" Image="/sysimg/32/heater_central_on_locked.png"/>
<Appliance Id="5" Name="Droger" Type="dryer" PowerUsage="0,0000" TotalUsage="1161,39" PowerState="on" Module="6" Image="/sysimg/32/dryer_on.png"/>
<Appliance Id="1" Name="HsProServer" Type="monitor" PowerUsage="0,0000" TotalUsage="49,03" PowerState="on" Module="2" Image="/sysimg/32/monitor_on_locked.png"/>
<Appliance Id="14" Name="Koelkast" Type="refrigerator" PowerUsage="0,0000" TotalUsage="700,04" PowerState="on" Module="15" Image="/sysimg/32/refrigerator_on.png"/>
<Appliance Id="8" Name="Magnetron" Type="oven_microwave" PowerUsage="1,0000" TotalUsage="56,97" PowerState="on" Module="9" Image="/sysimg/32/oven_microwave_on.png"/>
<Appliance Id="2" Name="MediaCenter" Type="hometheater" PowerUsage="0,0000" TotalUsage="206,49" PowerState="unknown" Module="3" Image="/sysimg/32/hometheater_unknown_locked.png"/>
<Appliance Id="3" Name="Multimedia" Type="hometheater" PowerUsage="36,0000" TotalUsage="433,33" PowerState="on" Module="4" Image="/sysimg/32/hometheater_on.png"/>
<Appliance Id="10" Name="ongebruikt" Type="zz_misc" PowerUsage="0,0000" TotalUsage="19,24" PowerState="unknown" Module="11" Image="/sysimg/32/zz_misc_unknown.png"/>
<Appliance Id="17" Name="Ongebruikt2" Type="zz_misc" PowerUsage="0,0000" TotalUsage="40,99" PowerState="unknown" Module="18" Image="/sysimg/32/zz_misc_unknown.png"/>
<Appliance Id="6" Name="PcEd" Type="computer_desktop" PowerUsage="0,0000" TotalUsage="4,59" PowerState="unknown" Module="7" Image="/sysimg/32/computer_desktop_unknown.png"/>
<Appliance Id="4" Name="Router" Type="router" PowerUsage="24,0000" TotalUsage="44,83" PowerState="on" Module="5" Image="/sysimg/32/router_on_locked.png"/>
<Appliance Id="11" Name="Senseo" Type="coffee_maker" PowerUsage="1,0000" TotalUsage="75,64" PowerState="on" Module="12" Image="/sysimg/32/coffee_maker_on.png"/>
<Appliance Id="16" Name="Televisie" Type="tv" PowerUsage="0,0000" TotalUsage="567,99" PowerState="on" Module="17" Image="/sysimg/32/tv_on.png"/>
<Appliance Id="12" Name="TvSlaapkamer" Type="tv" PowerUsage="0,0000" TotalUsage="61,55" PowerState="off" Module="13" Image="/sysimg/32/tv_off.png"/>
<Appliance Id="15" Name="VijverPomp" Type="pump_heater" PowerUsage="2,0000" TotalUsage="46,50" PowerState="unknown" Module="16" Image="/sysimg/32/pump_heater_unknown.png"/>
<Appliance Id="7" Name="Wasmachine" Type="washingmachine" PowerUsage="0,0000" TotalUsage="382,05" PowerState="on" Module="8" Image="/sysimg/32/washingmachine_on.png"/>
Could someone help me with this?
Thanks
Regards
Edwin
So there be devices with the given info from the xml file in domoticz.
Example : CloseInBoiler status=on usage=0W
See my xml file:
<PlugwiseSource Version="1.0">
<Appliances>
<Appliance Id="13" Name="CloseInBoiler" Type="water_heater_vessel" PowerUsage="0,0000" TotalUsage="927,83" PowerState="on" Module="14" Image="/sysimg/32/water_heater_vessel_on.png"/>
<Appliance Id="9" Name="CV-ketel" Type="heater_central" PowerUsage="69,0000" TotalUsage="394,95" PowerState="on" Module="10" Image="/sysimg/32/heater_central_on_locked.png"/>
<Appliance Id="5" Name="Droger" Type="dryer" PowerUsage="0,0000" TotalUsage="1161,39" PowerState="on" Module="6" Image="/sysimg/32/dryer_on.png"/>
<Appliance Id="1" Name="HsProServer" Type="monitor" PowerUsage="0,0000" TotalUsage="49,03" PowerState="on" Module="2" Image="/sysimg/32/monitor_on_locked.png"/>
<Appliance Id="14" Name="Koelkast" Type="refrigerator" PowerUsage="0,0000" TotalUsage="700,04" PowerState="on" Module="15" Image="/sysimg/32/refrigerator_on.png"/>
<Appliance Id="8" Name="Magnetron" Type="oven_microwave" PowerUsage="1,0000" TotalUsage="56,97" PowerState="on" Module="9" Image="/sysimg/32/oven_microwave_on.png"/>
<Appliance Id="2" Name="MediaCenter" Type="hometheater" PowerUsage="0,0000" TotalUsage="206,49" PowerState="unknown" Module="3" Image="/sysimg/32/hometheater_unknown_locked.png"/>
<Appliance Id="3" Name="Multimedia" Type="hometheater" PowerUsage="36,0000" TotalUsage="433,33" PowerState="on" Module="4" Image="/sysimg/32/hometheater_on.png"/>
<Appliance Id="10" Name="ongebruikt" Type="zz_misc" PowerUsage="0,0000" TotalUsage="19,24" PowerState="unknown" Module="11" Image="/sysimg/32/zz_misc_unknown.png"/>
<Appliance Id="17" Name="Ongebruikt2" Type="zz_misc" PowerUsage="0,0000" TotalUsage="40,99" PowerState="unknown" Module="18" Image="/sysimg/32/zz_misc_unknown.png"/>
<Appliance Id="6" Name="PcEd" Type="computer_desktop" PowerUsage="0,0000" TotalUsage="4,59" PowerState="unknown" Module="7" Image="/sysimg/32/computer_desktop_unknown.png"/>
<Appliance Id="4" Name="Router" Type="router" PowerUsage="24,0000" TotalUsage="44,83" PowerState="on" Module="5" Image="/sysimg/32/router_on_locked.png"/>
<Appliance Id="11" Name="Senseo" Type="coffee_maker" PowerUsage="1,0000" TotalUsage="75,64" PowerState="on" Module="12" Image="/sysimg/32/coffee_maker_on.png"/>
<Appliance Id="16" Name="Televisie" Type="tv" PowerUsage="0,0000" TotalUsage="567,99" PowerState="on" Module="17" Image="/sysimg/32/tv_on.png"/>
<Appliance Id="12" Name="TvSlaapkamer" Type="tv" PowerUsage="0,0000" TotalUsage="61,55" PowerState="off" Module="13" Image="/sysimg/32/tv_off.png"/>
<Appliance Id="15" Name="VijverPomp" Type="pump_heater" PowerUsage="2,0000" TotalUsage="46,50" PowerState="unknown" Module="16" Image="/sysimg/32/pump_heater_unknown.png"/>
<Appliance Id="7" Name="Wasmachine" Type="washingmachine" PowerUsage="0,0000" TotalUsage="382,05" PowerState="on" Module="8" Image="/sysimg/32/washingmachine_on.png"/>
Could someone help me with this?
Thanks
Regards
Edwin
Last edited by edwin1234 on Monday 02 January 2017 16:03, edited 1 time in total.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Xml in domoticz?
Should be possible with PHP.
I use this command to get the status of a Denon receiver wich is also presented in XML format:
Values are then available in a associated array, for ex:
the function file_get_contents can be url or local file.
I use this command to get the status of a Denon receiver wich is also presented in XML format:
Code: Select all
$denonmain=json_decode(json_encode(simplexml_load_string(file_get_contents($denon_address.'/goform/formMainZone_MainZoneXml.xml?_='.time(),false,$ctx))),TRUE);Code: Select all
$denonmain['ZonePower']['value']- Westcott
- Posts: 423
- Joined: Tuesday 09 December 2014 17:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: UK - Glos
- Contact:
Re: Xml in domoticz?
It can also be done directly in Lua, just like JSON.
There's an XML.lua file available, and LuaRocks has at least one library.
There's an XML.lua file available, and LuaRocks has at least one library.
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
-
edwin1234
- Posts: 330
- Joined: Sunday 09 October 2016 20:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Nederland
- Contact:
Re: Xml in domoticz?
Thanks for your help
but Cant get it done in lua example.xml i get errors i do something wrong.
Can u please give me a filled in example? What to fill in at : s = request['content'];
sorry total new to scripting
My xml is:
http://192.168.2.166:port/xml/appliances.xml
-- Example of XML parser handling data with the following structure
--<?xml version="1.0" encoding="UTF-8"?>
--<sensor>
-- <id>13</id>
-- <value>29.99</value>
--</sensor>
--}
-- A test with curl would be : curl -X POST -d "@test.xml" 'http://192.168.1.17:8080/json.htm?type= ... le_xml.lua'
-- Retrieve the request content
s = request['content'];
-- Update some devices (index are here for this example)
local id = domoticz_applyXPath(s,'//id/text()')
local s = domoticz_applyXPath(s,'//value/text()')
domoticz_updateDevice(id,'',s)
but Cant get it done in lua example.xml i get errors i do something wrong.
Can u please give me a filled in example? What to fill in at : s = request['content'];
sorry total new to scripting
My xml is:
http://192.168.2.166:port/xml/appliances.xml
-- Example of XML parser handling data with the following structure
--<?xml version="1.0" encoding="UTF-8"?>
--<sensor>
-- <id>13</id>
-- <value>29.99</value>
--</sensor>
--}
-- A test with curl would be : curl -X POST -d "@test.xml" 'http://192.168.1.17:8080/json.htm?type= ... le_xml.lua'
-- Retrieve the request content
s = request['content'];
-- Update some devices (index are here for this example)
local id = domoticz_applyXPath(s,'//id/text()')
local s = domoticz_applyXPath(s,'//value/text()')
domoticz_updateDevice(id,'',s)
-
edwin1234
- Posts: 330
- Joined: Sunday 09 October 2016 20:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Nederland
- Contact:
Re: Xml in domoticz?
nobody?
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Xml in domoticz?
You know it's very agressive to bump your topic with a comment like that?
I provided a way but you didn't even bother to try or respond on it.
I provided a way but you didn't even bother to try or respond on it.
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Re: Xml in domoticz?
Advise to first use (in future) the search-function in this forum, because at least 2 other, older threads which follow the line of your question, and may provide a solution:
http://www.domoticz.com/forum/viewtopic.php?f=28&t=1837
http://www.domoticz.com/forum/viewtopic ... 23&t=11472
http://www.domoticz.com/forum/viewtopic.php?f=28&t=1837
http://www.domoticz.com/forum/viewtopic ... 23&t=11472
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
-
edwin1234
- Posts: 330
- Joined: Sunday 09 October 2016 20:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Nederland
- Contact:
Re: Xml in domoticz?
Sorry didnt ment it that way, i did try the xml.lua filled in my ip and the line of the xml
But i only get errors.
I told in my previous post that i dont have scripting experience or program skills , so its hard for me to understand the script. I search the internet for something simmulair but couldt find it.
Im very thankfull for your help and answer,
I Will wait for a solution that i understand
Thanks
Regards
Edwin
But i only get errors.
I told in my previous post that i dont have scripting experience or program skills , so its hard for me to understand the script. I search the internet for something simmulair but couldt find it.
Im very thankfull for your help and answer,
I Will wait for a solution that i understand
Thanks
Regards
Edwin
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Xml in domoticz?
The php solution is pretty simple and straight forward AND there's a HUGE userbase for php, so you'll find anything for it.
-
edwin1234
- Posts: 330
- Joined: Sunday 09 October 2016 20:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Nederland
- Contact:
Re: Xml in domoticz?
Thanks monday for your php solution,
Can u tell me how i get the outcome in domoticz?
Regards
Edwin
Can u tell me how i get the outcome in domoticz?
Regards
Edwin
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Xml in domoticz?
Best way to go is first set up a PHP enabled webserver if you don't have that already.
Then create a PHP file with the function posted above and loop through the array until you have the desired values in variables.
Then put those variables in a json command to sent them to domoticz.
Then create a PHP file with the function posted above and loop through the array until you have the desired values in variables.
Then put those variables in a json command to sent them to domoticz.
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Re: Xml in domoticz?
For experimenting/learning to work with a PHP-enabled webserver looking for a small software package (of at least Apache/PHP/SQL) to run at one of the local 'leftover-PCs' with WindowsXP. Have been trying to install&configure Xitami+PHP5 and as alternative EasyPHPDevserver, but still meet problems. Xitami+PHP5 is rather small, but limited (e.g. no SQL_DB). EasyPHP-package is complete, but rather big for the available PCs.
Any other, simple & small & robust package recommended?
Any other, simple & small & robust package recommended?
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Who is online
Users browsing this forum: No registered users and 1 guest