Page 1 of 1

2 devices displayed in 1 dummy device, is that possible?

Posted: Tuesday 08 December 2020 1:09
by HvdW
Hi,

I am displaying Watt usage of my Shelly 2.5 switch.
That is to say; For one channel of the switch it is straightforward.
I was wondering if it is possible to display both Watt usage lines in one graph.

Here is the code:

Code: Select all

-- Shelly (get watt)
-- Howto at Luftdaten https://www.domoticz.com/forum/viewtopic.php?f=72&t=23406&hilit=luftdaten
-- Call Shelly with http://192.168.x.x/status
--local Shelly = 'Shelly 20-0'

return {
	active = true,
	on = {
		timer = { 'every 10 minutes' },            -- every minute for testing, 10 minutes when active
		httpResponses = { 'Shelly20Retrieved' }  -- matches callback string below
	},
	execute = function(domoticz, item)

		if (item.isTimer) then
			domoticz.openURL({
				url = 'http://192.168.2.20/status',
				method = 'GET',
				callback = 'Shelly20Retrieved'
			})

		elseif (item.isHTTPResponse) then
			if (item.ok and item.isJSON) then
			   	domoticz.devices('Shelly 20').updateCustomSensor(item.json.meters[1].power)                
				domoticz.devices('Shelly 20').updateCustomSensor(item.json.meters[2].power)
		else
				-- oops
				domoticz.log('Error fetching Shelly data', domoticz.LOG_ERROR)
				domoticz.log(item.data, domoticz.LOG_ERROR)
			end
		end
	end
}
and here is the graph:
Capture.PNG
Capture.PNG (18.49 KiB) Viewed 210 times