Page 1 of 1

Tasker and AutoTools Json Read

Posted: Saturday 14 January 2017 21:25
by mlamie
I have read through several topics on this forum and have not seen any complete guide how to setup Domoticz in combination with Tasker. I'm experimenting and all I have now is a on/off switch command based on a fixed HTTP GET command. Quite straight forward. Some time ago AutoTools is released and can read JSON now.

If I use this:
[url]http://<username:password@>domoticz-ip<:port>/json.htm?type=devices&filter=all&used=true&order=Name[/url]
- <username:password@> = the username and password to access Domoticz, this is optional.
- domoticz-ip = the IP-address or hostname of your Domoticz installation.
- <:port> = the port number of your Domoticz installation, this is optional.

I do get a nice list with all the device and with the explanation of the AutoTools Json Read - Getting Started page I can get some flash messages which make sense, but flash messages are quite useless. Is there someone who can help to get some practical automation tasks done? Write those values as variables, implement those variables in tasks etc...

Re: Tasker and AutoTools Json Read

Posted: Friday 27 January 2017 5:05
by Javier
Hi mlamie,

There is no need to use a Json, but it can make things easier. Here is a task from the app I created with tasker which requests the domoticz data and writes it to a file without AutoTools...you can then read the file and extract device names and IDs..The full tasker project xml is on github if you are interested.

Code: Select all

<?xml version="1.0"?>

-<TaskerData tv="4.9u4m" dvi="1" sr="">


-<Task sr="task332">

<cdate>1438232751682</cdate>

<edate>1443915376158</edate>

<id>332</id>

<nme>Parse Domoticz Switches 1</nme>

<pri>100</pri>


-<Action sr="act0" ve="7">

<code>37</code>


-<ConditionList sr="if">

<bool0>And</bool0>


-<Condition sr="c0" ve="3">

<lhs>%DOMOTICZ_username</lhs>

<op>12</op>

<rhs/>

</Condition>


-<Condition sr="c1" ve="3">

<lhs>%DOMOTICZ_password</lhs>

<op>12</op>

<rhs/>

</Condition>

</ConditionList>

</Action>


-<Action sr="act1" ve="7">

<code>118</code>

<label>Request all lights and switches, if domoticz password IS set</label>

<Str sr="arg0" ve="3">http://%DOMOTICZ_username:%DOMOTICZ_password@%DOMOTICZ_ipaddress:%DOMOTICZ_port/json.htm?type=command&param=getlightswitches</Str>

<Str sr="arg1" ve="3"/>

<Str sr="arg2" ve="3"/>

<Str sr="arg3" ve="3"/>

<Str sr="arg4" ve="3"/>

<Int sr="arg5" val="10"/>

<Str sr="arg6" ve="3"/>

<Str sr="arg7" ve="3"/>

<Int sr="arg8" val="0"/>

</Action>


-<Action sr="act10" ve="7">

<code>39</code>

<Str sr="arg0" ve="3">%deviceinfo</Str>

<Str sr="arg1" ve="3">%testhttp()</Str>

</Action>


-<Action sr="act11" ve="7">

<code>590</code>

<Str sr="arg0" ve="3">%deviceinfo</Str>

<Str sr="arg1" ve="3">"idx" : "</Str>

<Int sr="arg2" val="0"/>

</Action>


-<Action sr="act12" ve="7">

<code>547</code>

<Str sr="arg0" ve="3">%nameinfo</Str>

<Str sr="arg1" ve="3">%deviceinfo(1)</Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="0"/>

<Int sr="arg4" val="0"/>

</Action>


-<Action sr="act13" ve="7">

<code>590</code>

<Str sr="arg0" ve="3">%nameinfo</Str>

<Str sr="arg1" ve="3">%rtn</Str>

<Int sr="arg2" val="0"/>

</Action>


-<Action sr="act14" ve="7">

<code>598</code>

<Str sr="arg0" ve="3">%nameinfo(1)</Str>

<Str sr="arg1" ve="3">",</Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="0"/>

<Int sr="arg4" val="0"/>

<Str sr="arg5" ve="3"/>

<Int sr="arg6" val="1"/>

<Str sr="arg7" ve="3"/>

</Action>


-<Action sr="act15" ve="7">

<code>598</code>

<label>removes white space from the beginning and the end of the string</label>

<Str sr="arg0" ve="3">%nameinfo(1)</Str>

<Str sr="arg1" ve="3">\A\s+|\s+\z</Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="1"/>

<Int sr="arg4" val="0"/>

<Str sr="arg5" ve="3"/>

<Int sr="arg6" val="1"/>

<Str sr="arg7" ve="3"/>

</Action>


-<Action sr="act16" ve="7">

<code>547</code>

<Str sr="arg0" ve="3">%name</Str>

<Str sr="arg1" ve="3">%nameinfo(1)</Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="0"/>

<Int sr="arg4" val="0"/>

</Action>


-<Action sr="act17" ve="7">

<code>548</code>

<on>false</on>

<Str sr="arg0" ve="3">%name</Str>

<Int sr="arg1" val="0"/>

</Action>


-<Action sr="act18" ve="7">

<code>355</code>

<Str sr="arg0" ve="3">%namelist</Str>

<Int sr="arg1" val="1"/>

<Str sr="arg2" ve="3">%name</Str>

<Int sr="arg3" val="0"/>

</Action>


-<Action sr="act19" ve="7">

<code>547</code>

<Str sr="arg0" ve="3">%idxinfo</Str>

<Str sr="arg1" ve="3">%deviceinfo(2)</Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="0"/>

<Int sr="arg4" val="0"/>

</Action>


-<Action sr="act2" ve="7">

<code>43</code>

</Action>


-<Action sr="act20" ve="7">

<code>590</code>

<Str sr="arg0" ve="3">%idxinfo</Str>

<Str sr="arg1" ve="3">%rtn</Str>

<Int sr="arg2" val="0"/>

</Action>


-<Action sr="act21" ve="7">

<code>598</code>

<Str sr="arg0" ve="3">%idxinfo(1)</Str>

<Str sr="arg1" ve="3">"</Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="0"/>

<Int sr="arg4" val="0"/>

<Str sr="arg5" ve="3"/>

<Int sr="arg6" val="1"/>

<Str sr="arg7" ve="3"/>

</Action>


-<Action sr="act22" ve="7">

<code>598</code>

<label>removes white space from the beginning and the end of the string</label>

<Str sr="arg0" ve="3">%idxinfo(1)</Str>

<Str sr="arg1" ve="3">\A\s+|\s+\z</Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="1"/>

<Int sr="arg4" val="0"/>

<Str sr="arg5" ve="3"/>

<Int sr="arg6" val="1"/>

<Str sr="arg7" ve="3"/>

</Action>


-<Action sr="act23" ve="7">

<code>547</code>

<Str sr="arg0" ve="3">%idx</Str>

<Str sr="arg1" ve="3">%idxinfo(1)</Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="0"/>

<Int sr="arg4" val="0"/>

</Action>


-<Action sr="act24" ve="7">

<code>548</code>

<on>false</on>

<Str sr="arg0" ve="3">%idx</Str>

<Int sr="arg1" val="0"/>

</Action>


-<Action sr="act25" ve="7">

<code>355</code>

<Str sr="arg0" ve="3">%idxlist</Str>

<Int sr="arg1" val="1"/>

<Str sr="arg2" ve="3">%idx</Str>

<Int sr="arg3" val="0"/>

</Action>


-<Action sr="act26" ve="7">

<code>548</code>

<on>false</on>

<Str sr="arg0" ve="3">%name:%idx</Str>

<Int sr="arg1" val="0"/>

</Action>


-<Action sr="act27" ve="7">

<code>40</code>

</Action>


-<Action sr="act28" ve="7">

<code>37</code>


-<ConditionList sr="if">


-<Condition sr="c0" ve="3">

<lhs>%namelist(1)</lhs>

<op>12</op>

<rhs/>

</Condition>

</ConditionList>

</Action>


-<Action sr="act29" ve="7">

<code>548</code>

<Str sr="arg0" ve="3">Get Domoticz devices succeeded!</Str>

<Int sr="arg1" val="0"/>

</Action>


-<Action sr="act3" ve="7">

<code>118</code>

<label>Request all lights and switches, if domoticz password is NOT set</label>

<Str sr="arg0" ve="3">http://%DOMOTICZ_ipaddress:%DOMOTICZ_port/json.htm?type=command&param=getlightswitches</Str>

<Str sr="arg1" ve="3"/>

<Str sr="arg2" ve="3"/>

<Str sr="arg3" ve="3"/>

<Str sr="arg4" ve="3"/>

<Int sr="arg5" val="10"/>

<Str sr="arg6" ve="3"/>

<Str sr="arg7" ve="3"/>

<Int sr="arg8" val="0"/>

</Action>


-<Action sr="act30" ve="7">

<code>410</code>

<Str sr="arg0" ve="3">HA Chaining Voice Commands/DZnamstoaddrs.txt</Str>

<Str sr="arg1" ve="3">%namelist():::%idxlist()</Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="0"/>

</Action>


-<Action sr="act31" ve="7">

<code>43</code>

</Action>


-<Action sr="act32" ve="7">

<code>548</code>

<Str sr="arg0" ve="3">Get Domoticz devices failed!</Str>

<Int sr="arg1" val="0"/>

</Action>


-<Action sr="act33" ve="7">

<code>38</code>

</Action>


-<Action sr="act4" ve="7">

<code>38</code>

</Action>


-<Action sr="act5" ve="7">

<code>547</code>

<Str sr="arg0" ve="3">%testhttp</Str>

<Str sr="arg1" ve="3">%HTTPD</Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="0"/>

<Int sr="arg4" val="0"/>

</Action>


-<Action sr="act6" ve="7">

<code>417</code>

<label>Example of data received from domoticz request as I do not have domoticz</label>

<on>false</on>

<Str sr="arg0" ve="3">HA Chaining Voice Commands/DomoticzGetLightSwitches.txt</Str>

<Str sr="arg1" ve="3">%testhttp</Str>

</Action>


-<Action sr="act7" ve="7">

<code>590</code>

<Str sr="arg0" ve="3">%testhttp</Str>

<Str sr="arg1" ve="3">"Name" : "</Str>

<Int sr="arg2" val="0"/>

</Action>


-<Action sr="act8" ve="7">

<code>356</code>

<Str sr="arg0" ve="3">%testhttp</Str>

<Int sr="arg1" val="1"/>

<Str sr="arg2" ve="3"/>

</Action>


-<Action sr="act9" ve="7">

<code>547</code>

<Str sr="arg0" ve="3">%rtn</Str>

<Str sr="arg1" ve="3"> </Str>

<Int sr="arg2" val="0"/>

<Int sr="arg3" val="0"/>

<Int sr="arg4" val="0"/>

</Action>

</Task>

</TaskerData>
Best,
Javier

Re: Tasker and AutoTools Json Read

Posted: Friday 15 May 2020 20:31
by galadril
old topic, but im looking into Tasker integrations with a plugin app
https://www.domoticz.com/forum/viewtopi ... 37&t=32696