VoxCommando
VoxNastics (User Guides and Mods) => XML Exchange => Topic started by: nime5ter on February 21, 2016, 11:41:43 AM
-
---
Unless you already have a good understanding of http requests, home automation, and VC, please start by reviewing Nodo's great, brief intro to Domoticz + VC:
http://voxcommando.com/forum/index.php?topic=2405.0
--
NOTE: You'll need to replace the Domoticz server IP address and port number in these commands with your own.
Personally, I store this info in a map table and access it as a map variable (http://voxcommando.com/mediawiki/index.php?title=Maps) so that I don't have to type the address manually for every scrape action.
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.6-->
<commandGroup open="True" name="Domoticz switches" enabled="True" prefix="" priority="0" requiredProcess="" description="">
<command id="173" name="Domoticz switch {1} to {2}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>Scrape</cmdType>
<params>
<param>http://{M:Domoticz.serverIP:Port}/json.htm?type=command&param=switchlight&idx={1}&switchcmd={2}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Domoticz switch</phrase>
<payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\domoticzSwitches.xml</payloadFromXML>
<phrase optional="true">to</phrase>
<payloadList>On,Off</payloadList>
</command>
<command id="149" name="Domoticz switches GenXML" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>PayloadXML.Clear</cmdType>
<params>
<param>payloads\domoticzSwitches.xml</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Scrape</cmdType>
<params>
<param>http://{M:Domoticz.serverIP:Port}/json.htm?type=command&param=getlightswitches</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.RegExSingle</cmdType>
<params>
<param>"Name"\s:\s"(.*?)".*?"Idx"\s:\s"(.*?)"</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.MatchToXML</cmdType>
<params>
<param>payloads\domoticzSwitches.xml</param>
<param>True</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>GenXML switches</phrase>
</command>
</commandGroup>
-
I forgot to post this command before, but it's part of the same 'package'.
Ask for the status (i.e. 'on' / 'off') of your switches, once you've generated a payload XML for them. (See above)
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.4-->
<command id="177" name="Get status of {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>Scrape</cmdType>
<params>
<param>http://{M:Domoticz.serverIP:Port}/json.htm?type=devices&rid={1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.RegExSingle</cmdType>
<params>
<param> result.*?"Status"\s:\s"(.*?)",</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>{PF.1} is {Match.1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>TTS.Speak</cmdType>
<params>
<param>{PF.1} is {Match.1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Get status of</phrase>
<payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\domoticzSwitches.xml</payloadFromXML>
</command>
Nodo has previously posted a link to the Domoticz documentation, but here is the page I used to figure out the correct Scrape URLs to use for these commands:
https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's