Is this scenario possible using domoticz?



  • I have been planning to build/use a sensor with domoticz but my skills are pretty limited. But I am wondering if this is possible:

    I have a sensor whish can output four different values depending on how the sensor is triggered, how do I send four different values to domoticz and what sensor type do I chose? I want in this example be able to light up four different lightbulbs in domoticz depending on the sensoroutput.

    I would also want to be able to use a local variable and a global variable. Can I somehow "push" a variable from domoticz to the sensor everytime it changes?



  • @Cliff-Karlsson
    I think it will be a problem send data from Domoticz to MySensors.
    I do not know any command in Domoticz.
    But if you use another hardware and sw, witch accepts http requests, for example ESP2866 with ESPeasy,
    it is possible.
    I use new dzVent script like this to send thermostat setpoint to my device every time, when is changed.

    return {
    	active = true, -- set to false to disable this script
    	on = {
    		devices = {
    			'Vychod_Setpoint'
    		}
    	},
    	execute = function(domoticz, device)
    	    local url= 'http://192.168.XXX.XXX/control?cmd=event,HeatSetpoint='..(device.state)..''
                print(url)
                domoticz.openURL(url)
            
    	end
    

    Instead of "devices" you can use "variables" to call script when Domoticz user variable changes.

    When you want send data to Domoticz:

    http://<username:password@>domoticz-ip<:port>/json.htm?type=command&param=switchlight&idx=99&switchcmd=On
    

    you switch On switch with idx 99

    This way you can send almost everything.

    For example power consumption 660W:

    http://<username:password@>domoticz-ip<:port>/json.htm?type=command&param=udevice&idx=28&nvalue=0&svalue=660;0
    

    The same Domoticz script with traditional LUA:

    commandArray = {}
            if devicechanged['Vychod_Setpoint'] then
                DomDevice = 'Vychod_Setpoint'
                DomValue = otherdevices_svalues[DomDevice]
                CalcValue = (DomValue*1)
                print(CalcValue)
                url= 'http://192.168.XXX.XXX/control?cmd=event,HeatSetpoint='..(CalcValue)..''
                print(url)
                commandArray['OpenURL']= url
            end
    return commandArray 
    


  • @Cliff-Karlsson Can you elaborate a little more on your project? What sensor type you choose would depend on what kind of sensor it is. Since you didn't tell us what that is, we can't very well recommend what type of sensor to choose.

    There are ways to send data to a MySensors device using LUA script, but again, not knowing what you are trying to do makes it hard to help.



  • @Cliff-Karlsson said in Is this scenario possible using domoticz?:

    I have a sensor whish can output four different values depending on how the sensor is triggered, how do I send four different values to domoticz and what sensor type do I chose? I want in this example be able to light up four different lightbulbs in domoticz depending on the sensoroutput.

    I have done this with my heat pump controller. I'm using dimmer and "linking" that to dummy selector what contains the states(0=off, 10=heat by water, 20=heat by room, 30=freeze protection...).
    Linking is done with LUA:

    --
    -- Heat pump mode selector<>dimmer mapping event
    --
    
    commandArray = {}
    
    selectorName = 'Pumppu_Mode'
    selectorId = '332'
    dimmerName = 'Pumppu_ModeSW2'
    
    -- selector -> native
    if(devicechanged[selectorName]) then
      iDimLevel = tonumber(otherdevices_svalues[selectorName])
      commandArray[dimmerName]='Set Level '..iDimLevel
    end
    
    -- native -> selector. (not triggering events this way of calling with UpdateDevice)
    if (devicechanged[dimmerName]) then
      if (devicechanged[dimmerName] == 'Off') then
        commandArray['UpdateDevice'] = selectorId..'|0|0'
      else
        iCurrentDimLevel = 0
        if(otherdevices[dimmerName] == 'On') then -- can be "On" or something else
          iCurrentDimLevel = tonumber(otherdevices_svalues[dimmerName])
        else
          iCurrentDimLevel = tonumber(string.match(otherdevices[dimmerName], "Set Level: (%d+) %%"))
        end
        
        commandArray['UpdateDevice'] = selectorId..'|'..iCurrentDimLevel..'|'..iCurrentDimLevel
      end
    end
    
    return commandArray
    

    I would also want to be able to use a local variable and a global variable. Can I somehow "push" a variable from domoticz to the sensor everytime it changes?

    Create a device to your sketch and use that to handle the "variable". The rest is just scripting in domoticz after that.


Log in to reply
 

Suggested Topics

  • 5
  • 8
  • 1
  • 1
  • 2
  • 5

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts