Skip to content

xConfiguration of Domoticz

arnemauer edited this page Mar 21, 2020 · 2 revisions

Create hardware in Domoticz

1. Create dummy hardware

  • If you already have a dummy device, skip this step and go to step 2.
  • Go to Setup -> Hardware
  • Fill in:
    Name: anything, e.g. "DUMMYHARDWARE" (this name is only used internally)
    Type: "Dummy (does nothing, use for virtual switches only)"
  • Click on 'Add'

2. Create a sensor for receiving ventilationmode-value from DUCO gateway

  • Click on 'Create Virtual Sensors' from the table of hardware above
  • Fill in:
    Name: "VentilationModeReceiver" (this name is displayed on the dashboard etc.)
    Sensor type: "Custom"
    Axis Label: "mode"
  • Click 'Ok'

3. Create a sensor for controlling the ventilationmode

  • Click on 'Create Virtual Sensors' from the table of hardware above
  • Fill in:
    Name: "VentilationMode" (this name is displayed on the dashboard etc.)
    Sensor type: "Switch"
  • Click 'Ok'

4. Change settings of ventilationMode control device

  • Go to Switches and find device "VentilationMode".
  • Click on "Edit"
  • Fill in:
    Switch Type: "Selector"
    Switch Icon: "Fan"
    Protected: "Off"
    Hide Off level: "On"
    Selector Levels:

Create dzVents scripts

5. Global variables script

  • Firstly we need to make a script that stores global variables. You can only have one globaldata-script! If you already have a global Data-script you can add the variables to it.
  • Go to Setup => more options => Events
  • Click on "+" to add a new automation script
  • Select "dzVents" => "Global Data"
  • Replace the script with:
-- this scripts holds all the globally persistent variables and helper functions
-- see the documentation in the wiki
-- NOTE:
-- THERE CAN BE ONLY ONE global_data SCRIPT in your Domoticz install.

return {
	-- global persistent data
	data = {
		ventilationModeChangedByDucoBox = { initial = false }
	},

	-- global helper functions
	helpers = {
		myHelperFunction = function(domoticz)
			-- code
		end
	}
}

6. Receive new status script

  • Click on "+" to add a new automation script
  • Select "dzVents" => "Minimal"
  • Name: "DUCORF_RECEIVE_NEW_STATUS"
  • Replace the script and save it.

DUCORF_RECEIVE_NEW_STATUS:

return {
	on = {
		devices = {
			'VentilationModeReceiver'
		}
	},
	execute = function(domoticz, device) 
	    
        local state = 0
        local state_readable = 'UNKNOWN STATE'
        
        if(device.state == '0') then     
            state = 10             
            state_readable = 'AUTO'
        elseif(device.state == '1') then 
            state = 20
            state_readable = 'LOW'
        elseif(device.state == '2') then 
            state = 30
            state_readable = 'MIDDLE'
        elseif(device.state == '3') then 
            state = 40
            state_readable = 'HIGH'
        elseif(device.state == '4') then 
            state = 50
            state_readable = 'NOTHOME'
        end

        domoticz.log('Received statusupdate from gateway (' .. device.state .. ' => ' .. state ..'/' .. state_readable .. ')', domoticz.LOG_INFO)
        
        if(domoticz.devices('VentilationMode').level == state) then
            domoticz.log('No new ventilation state. Not updating ' .. domoticz.devices('VentilationMode').name, domoticz.LOG_INFO)
        else
            domoticz.log('New ventilation state. Changing state of  ' .. domoticz.devices('VentilationMode').name, domoticz.LOG_INFO)
            domoticz.devices('VentilationMode').switchSelector(state)

            -- set global variable ventilationModeChangedByDucoBox to true, so ventilation changemode script isnt sending a command to duco RF gateway
            domoticz.globalData.ventilationModeChangedByDucoBox  = true
       end
       
    end
}

7. Ventilationmode changed script

  • Click on "+" to add a new automation script
  • Select "dzVents" => "Minimal"
  • Name: "DUCORF_VENTILATIONMODE_CHANGED"
  • Replace the script and save it.

DUCORF_VENTILATIONMODE_CHANGED:

return {
	on = {
		devices = {
			'VentilationMode'
		}
	},
	execute = function(domoticz, device)
        --device.dump()
   
   	   if(domoticz.globalData.ventilationModeChangedByDucoBox) then
	       domoticz.log('Ventilationmode not changed because ventilationmode changed by Ducobox.', domoticz.LOG_INFO)
           domoticz.globalData.ventilationModeChangedByDucoBox = false;
        else
            
            local newMode = 0;
            domoticz.log('Ventilationlevel: '..device.level..'. Ventilation state: '.. domoticz.devices('VentilationMode').state , domoticz.LOG_INFO)
    
    	    if(device.level == 10) then
    	        newMode = 'AUTO';
    	    elseif(device.level == 20) then
    	        newMode = 'LOW';
    	    elseif(device.level == 30 ) then
    	        newMode = 'MIDDLE';
    	    elseif(device.level == 40) then
    	        newMode = 'HIGH';
    	    elseif(device.level == 50 ) then
    	        newMode = 'NOTHOME';
    	    end
	       
	       domoticz.log('Sending command to DUCO GW to change ventilationmode to: '..newMode , domoticz.LOG_INFO)
	       domoticz.openURL('http://192.168.XXX.XXX/control?cmd=VENTMODE,'.. newMode ..',0')
	       domoticz.log('Ventilationmode changed in: '..device.level..'. Device mode: '.. newMode , domoticz.LOG_INFO)
        end
	end
}
  • Change 192.168.XXX.XXX to de IP-address of your DUCO Gateway.

Configure RF gateway to send data to domoticz

8. Configure domoticz controller

  • Go to the ESP Easy webpage (http://192.168.x.x)
  • Go to 'Controllers' and click on 'Edit' of a controller
  • Fill in:
    Protocol: Domoticz HTTP \ Controller IP: 192.168.2.xxx (IP of Domoticz)
    Controller Port: 80 (port of Domoticz)
    Controller User:
    Controller Password:
    Enabled: checked

9. Find IDX

  • Go to the Domoticz controlpanel
  • Go to Setup => Device
  • Find device 'VentilationModeReceiver' and write down the IDX.

10. Configure IDX

  • Go to the ESP Easy webpage (http://192.168.x.x)
  • Go to 'Devices'
  • Find 'DUCO ventilation remote' and click on 'Edit'
  • Check "Send to Controller"
  • Fill the IDX of 'VentilationModeReceiver' you wrote down earlier in the field IDX
  • Click on 'Save'

Test it!

  • Test if you can change the ventilationmode in Domoticz. If it does... do some nice home automation tricks!
  • Test if you receive the new status when you manually changing the status with a duco remote.
Clone this wiki locally