How do I change a variable in domoticz from a sensor-reading?
I have created a integer variable in domoticz that I want to change depending on a sensor reading. I just want to understand how this is done so my current sketch is not very useful.
I have a Ultrasonic sensor that I want to use to update the custom variable in domotics.
If range is over 100cm -> set domoticz variable value to "1"
If range is over 200cm -> set domoticz variable value to "2"
and so on...
@Cliff-Karlsson - One way is LUA which is the only way I know. Might be something from the GUI as well?
if ( commandArray["RangeSensor"] > "100" ) then uservariables['Variable:MyVar']= "1"
Check more here: https://www.domoticz.com/wiki/User_variables
e way is LUA which is the only way I know. Might be something from the GUI as well?
@sundberg84 thanks, I guess that I was unclear about the usage. I do not want to present a distance-sensor to domoticz. I want to use a distance-sensor and only present some sort of sensor that only recieves the current number from the sketch.
I tried to make another example of what I want to do:
I am experementing and have built a very simple sensors with two ir beams that is placed in a row near a door. When I walk through from one side it registers a variable+=1 and when I walk the other way it registers - =1. My plan is to use something similar to be able to register if a room is occupied and also the number of persons in that room.
If I already have the sensor how do I integrate that functionality into domoticz? I guess the occupied/unoccupied part could be solved by the sensor itself by acting like a switch and report "on" or similar when number of occupants in the room is greater than zero. But it would be nicer if it was also possible to get the actual number of persons and maybe something other than a on/off switch - icon.
And if I have a room with multiple doorways it will not work very well as I need to be able to have multiple sensors that can modify the same variable.
Is there some way that I can add a custom variable in domoticz called for example "livingroom" and have sensors that update the same variable on change. Like : sensor 1-> livingroom +=1, Trigger some switch to livingroom occupied then sensor 2-> livingroom -=1, triggers the same switch to unoccupied.
Is this possible? And how would I register those sensors to domoticz and what do I send to be able to modify the domoticz custom variable?