Page 1 of 1

Remote XMLAPI for sensors and switches

Posted: Sunday 03 January 2016 21:42
by mrcage
Hi,

Let me introduce me first. I'm Martijn, from the Netherlands and just started with Domoticz.
I currently have a Control4 system which is working fine however expanding it is pretty expensive and should be done by an installer.
I'd like to be in the driver seat ;)

I currently have HomeMatic for my lightning and Motion detectors and I would love to get them running in Domoticz.
Switching is easy done by: http://192.168.1.52/config/xmlapi/state ... se_id=1822[/b]&new_value=1
The PIRs have a similar string value="false" or value="true"

But It should be nice if I can somehow trigger/read what the current status is

<channel name="<ChannelName>:1" ise_id="1822" visible="true" operate="true">
<datapoint name="<DatapointName:1.LEVEL" type="LEVEL" ise_id="1594" value="1.000000" valuetype="6" valueunit="100%" timestamp="1451852268" operations="7"/>

Is this possible by the UI or should I write a (LUA) script for this?

Re: Remote XMLAPI for sensors and switches

Posted: Sunday 03 January 2016 22:07
by malarcy
Triggering should be easy - add yourself the dummy hardware - create a switch (you can use any type - I "pretend" things are x10 type in that case you set a house and unit code - they are not used they just create a unique switch) on that hardware - and then edit the resulting switch - in there is an on and off action - and you can put http:// actions in there for your on/off switches.

I think there is a way read values for sensors from http - but I don't know how to do that (I am about 30 days ahead of you in Domoticz experience).

Once the system has the switch - you can script it via the various interfaces and combine it with other sensors.

Enjoy the learning

Hope this helps

Re: Remote XMLAPI for sensors and switches

Posted: Sunday 03 January 2016 22:30
by mrcage
Thanks,

The switches are working fine sofar..
The thing is that I want to know the current status. Say for instance..

I use a manual wall switch to turn on the light.
Then I want to see this status change in Domoticz.

This should be possible as sensors behave the same. Thing I can't find (sofar) in Domoticz is how to poll the switches/sensors using a xmlapi.
I do have the code, just do no where to put it ;)

Re: Remote XMLAPI for sensors and switches

Posted: Sunday 03 January 2016 22:56
by malarcy
you could run it in a script (lua) as a "time" event - they run every minute - and you could update the status from that script - there may be a side effect of any on action (like the http:// string) being run when you update the status.

Not sure if that would be suitable for motion sensors though

Re: Remote XMLAPI for sensors and switches

Posted: Monday 04 January 2016 22:47
by mrcage
Ok,

I tried to do it the other way around.
Instead of polling Homematic from Domoticz I added a script in Homematic.
This updates a user variable, some UTF crap forced me to call a webservice first

/// HomeMatic script
string stderr;
string stdout;
string url="http://192.168.1.10/webservice/motion.p ... Downstairs";
system.Exec("wget -q -O - "#url, &stdout, &stderr);

So now I have 2 user variables:
PIR_Upstairs Integer 0 2016-01-04 22:42:10
PIR_Downstairs Integer 0 2016-01-04 22:42:10

edit: I can trigger events when the PIR detects motion..
I love Domoticz :D