Gazpar counter via Zigbee switch button

Moderator: leecollings

Post Reply
oxygen
Posts: 9
Joined: Tuesday 02 October 2018 11:38
Target OS: -
Domoticz version:
Contact:

Gazpar counter via Zigbee switch button

Post by oxygen »

Hi all,

This is an workaround to connect easily/on the cheap the French Gazpar "smart" counter to domoticz using a Zigbee switch connected to the Gazpar output, based on the following setup.
I thought it was worth sharing as I couldn't find any example.

https://www.auto-domo.fr/home-assistant ... on-gazpar/

Overview:
The gazpar counter produces a dry contact for every 10L of gaz (1dm3) used.
This dry-contact/2pin output is connected to (any) Zigbee switch. A hit is then sent by the Zigbee switch every 10L.
This Zigbee switch is registered into domoticz (in my setup via a raspbee/deCONZ plugin)
And then parsed via a dzevents script into a virtual Gaz Counter into Domoticz.

In my setup, i'm using a IKEA/Somrig button.
https://www.ikea.com/fr/fr/p/somrig-lan ... -50560334/
https://github.com/dresden-elektronik/d ... utton.json
https://raw.githubusercontent.com/dresd ... _maps.json

Ikea/Somrig button in Domoticz has (up to) 10 different states.
Even states are for one of the two buttons.
Odd states are for the other one.
  • 10/20 is for a single short hit
  • 30/40 is for a double hit
  • 50/60 is for a long hit
(I couldn't find actions generating the values for 70/80/90/+)

In order to ensure all works, i've configured both in the dzevent script.

Simplified overview
Gazpar <--cable--> Ikea/Somrig Zigbee Switch {{<== Zigbee Radio Waves ==>} Raspbee/deCONZ <-- Ethernet --> Domoticz/zigbee plugin

Here is the dzevents script:

Code: Select all

-- ************************************************************ 
-- ** Manage Gazpar virtual Counter from Zigbee drycontact   **
-- ** Triggered every time the Zigbee devices receives a hit **
-- **
-- ** Gazpar counter: 1 hit per 10dm3/10L
-- **
-- ** Zigbee device: Two buttons
-- ** Zigbee device: Single hit : 10/20
-- ** Zigbee device: Dual hit (2 hits in less than 1 sec): 30/40
-- ** Zigbee device: Long hit (1-long hit in more than 1 sec): 50/60
        
return {
	on = {
		devices = {
			-- Zigbee device called by the Gazpar Smart counter
			'Raspbee-Gazpar',
			-- Test Fake device for simulation / test purpose
			'raspbee-gazpar-test',
			}
	},
	logging = {
		level = domoticz.LOG_DEBUG,
		marker = 'Gazpar',
	},
	
	execute = function(domoticz, device)
	    --domoticz.log('trigger == > '..device.trigger)
	        
	    local current_gazpar = domoticz.devices("Gazpar-Zigbee").counter
	    local zigbee_hit = domoticz.devices("Raspbee-Gazpar").level
	    -- local zigbee_hit = domoticz.devices("raspbee-gazpar-test").level
		domoticz.log('Gazpar // Device ' .. device.name .. ' was hit with ' .. tonumber(zigbee_hit), domoticz.LOG_INFO)

	    if zigbee_hit == 10 or zigbee_hit == 20 then
    		-- Single hit = +10L
    		domoticz.log('Single hit', domoticz.LOG_INFO)
    		domoticz.devices("Gazpar-Zigbee").updateGas(current_gazpar * 1000 + 10)
    		domoticz.log('Gazpar // Upgrade m3 from ' .. tonumber(current_gazpar) .. ' to ' .. tonumber(domoticz.devices("Gazpar-Zigbee").counter), domoticz.LOG_INFO)
    	elseif zigbee_hit == 30 or zigbee_hit == 40 then
            -- Dual hit = two close hits = +20L
    		domoticz.log('Dual hit', domoticz.LOG_INFO)
    		domoticz.devices("Gazpar-Zigbee").updateGas(current_gazpar * 1000 + 20)
    		domoticz.log('Gazpar // Upgrade m3 from ' .. tonumber(current_gazpar) .. ' to ' .. tonumber(domoticz.devices("Gazpar-Zigbee").counter), domoticz.LOG_INFO)
    	elseif zigbee_hit == 50 or zigbee_hit == 60 then
            -- Long hit = probably an error, but +10L anyway
    		domoticz.log('Long hit', domoticz.LOG_INFO)
    		domoticz.devices("Gazpar-Zigbee").updateGas(current_gazpar * 1000 + 10)
    		domoticz.log('Gazpar // Upgrade m3 from ' .. tonumber(current_gazpar) .. ' to ' .. tonumber(domoticz.devices("Gazpar-Zigbee").counter), domoticz.LOG_INFO)
    	else
    		domoticz.log('Another type of hit // we do nothing', domoticz.LOG_INFO)
    	    -- Use this to "reset" the Counter values (usefull during resync/1st setup)
    	    -- domoticz.devices("Gazpar-Zigbee").updateGas(123456789)
    	end
    	
	end

}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest