Page 1 of 1

Updating status of Virtual selector from device status

Posted: Friday 12 April 2019 8:36
by ciberyan
Hello

Hope to be in the right place as it related to heating but also to Domo itself and Zwave
To be short
I have a Qubino Zwave device to drive my electric heater (ZMNHJD1)
This one act as a dimmer so I have a block script to easily set the level with button instaed of value > this works well
But if I change directly on the device, I am out of sync with my selector
On this example I set the device to 45% and so I should be on CONFORT-1 on the selector
Unfortunately it seems to be a one way street, from selector to device but no in the other way
Image
Is there any mean to refresh the status of a virtual selector with the status of a real device
Thanks in advance for your idea

Re: Updating status of Virtual selector from device status

Posted: Saturday 13 April 2019 0:12
by waaren
ciberyan wrote: Friday 12 April 2019 8:36 I have a Qubino Zwave device to drive my electric heater (ZMNHJD1)
This one act as a dimmer so I have a block script to easily set the level with button instaed of value > this works well
But if I change directly on the device, I am out of sync with my selector
On this example I set the device to 45% and so I should be on CONFORT-1 on the selector
Unfortunately it seems to be a one way street, from selector to device but no in the other way
Is there any mean to refresh the status of a virtual selector with the status of a real device
See below dzvents script; it should work both ways.

When not yet familiar with dzVents please start with reading Get started Before implementing. Special attention please for
"In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."

Code: Select all

local dimmerDevice   = 'dimmer'
local selectorDevice = 'select'

return {	
			on =    {
						devices = {dimmerDevice, selectorDevice},
					},
              
    execute = function(dz, item)

		local selector = dz.devices(selectorDevice)
        local dimmer = dz.devices(dimmerDevice)
        
        local maxLevel = ( #selector.levelNames - 1 ) * 10
        
        if item.name == 'dimmer' then
            if item.level  < 1 and item.state ~= "On" then 
                selector.switchSelector(0) 
            elseif item.level  > 99 and item.state ~= "Off"  then 
                selector.switchSelector(selector.maxLevel)
            else 
                selector.switchSelector(dz.utils.round(item.level / 1000 * maxLevel) * 10 ).silent()
            end   
        else  -- = select
            dimmer.dimTo(selector.level / maxLevel * 100 ).silent()
        end

    end
} 

Re: Updating status of Virtual selector from device status

Posted: Saturday 13 April 2019 11:47
by ciberyan
Thanks for you help and direction
Some reading and understanding goal for this weekend I guess :D