Re: zwavejs2mqtt
Posted: Tuesday 02 November 2021 19:46
But if you do not use that device, how do you control the Spirit?
Code: Select all
action:
service: zwave.set_config_parameter
data_template: {
"node_id": 5,
"parameter": 72,
"value": 6,
"size": 1
}
Code: Select all
[Node 095] [REQ] [SendData]
│ transmit options: 0x25
│ callback id: 228
└─[ConfigurationCCSet]
parameter #: 72
reset to default: false
value size: 1
value format: SignedInteger
value: 6
That is their preferred communication method, but you can also use the MQTT AutoDiscover in HA!.
I've found how to do it with the help of the zwavejs2mqtt git discussions
Code: Select all
local LED_SELECTOR_ID = 887 -- dummy selector to manage the LED with predefined choices:
local LED_ANIMATION_AURORA = 10
local LED_ANIMATION_RAINBOW = 20
local LED_ANIMATION_STORM = 30
local LED_ANIMATION_FIREPLACE = 40
local LED_ANIMATION_LAPD = 50
local LED_ANIMATION_PAUSE = 60
-- zwavejs2mqtt
local mqtt_prefix = "zwave"
local NODE_nodeId = 95
local NODE_commandClass = 112
local NODE_endpoint = 0
local NODE_property = 72
return {
logging = { level =
--domoticz.LOG_ERROR, --select one to override system log level normal = LOG_ERROR
domoticz.LOG_DEBUG,
--domoticz.LOG_INFO,
--domoticz.LOG_ERROR,
--domoticz.LOG_FORCE
},
on = {
devices = {LED_SELECTOR_ID},
},
execute = function(dz, device)
_G.logMarker = dz.moduleLabel -- set logmarker to scriptname
--local LOG_LEVEL = dz.LOG_INFO -- LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE - normal = LOG_INFO
local LOG_LEVEL = dz.LOG_DEBUG
dz.log("LED_SELECTOR " .. device.state .. " " .. tostring(device.level) .. " nValue: " .. device.nValue, LOG_LEVEL)
-----< BEG FUNCTIONS > ----------------------------------------------------------------------------------------
local function logWrite(str, level) -- Support function for shorthand debug log statements
if level == nil then
level = LOG_LEVEL
end
dz.log(tostring(str), level)
end
local function setRGBWAnimation(rgbAnimation)
local codeAnimation
if rgbAnimation == LED_ANIMATION_PAUSE then
codeAnimation = 1
elseif rgbAnimation == LED_ANIMATION_FIREPLACE then
codeAnimation = 6
elseif rgbAnimation == LED_ANIMATION_STORM then
codeAnimation = 7
elseif rgbAnimation == LED_ANIMATION_RAINBOW then
codeAnimation = 8
elseif rgbAnimation == LED_ANIMATION_AURORA then
codeAnimation = 9
elseif rgbAnimation == LED_ANIMATION_LAPD then
codeAnimation = 10
end
local mqtt_prefix = "zwave"
local NODE_nodeId = 95
local NODE_commandClass = 112
local NODE_endpoint = 0
local NODE_property = 72
local NODE_value = codeAnimation
local suffix = "set"
--mqttTopic = "zwave/95/112/0/72/set"
local mqttTopic = mqtt_prefix .. '/' .. NODE_nodeId .. '/' .. NODE_commandClass .. '/' .. NODE_endpoint .. '/' .. NODE_property .. '/' .. suffix
local mosquitto_cmd = 'mosquitto_pub' ..' -t '.. mqttTopic .. ' -m '.. NODE_value
os.execute (mosquitto_cmd)
logWrite("mosquitto_cmd=" .. mosquitto_cmd)
end
-----< END FUNCTIONS > ----------------------------------------------------------------------------------------
setRGBWAnimation(device.level)
end
}
Code: Select all
--local ZModeOff = 'mosquitto_pub -h 127.0.0.1 -t zwavejs2mqtt/Zolder_Thermostaat/64/0/mode/set -m "{\\"value\\": 0}"'
--local ZModeEco = 'mosquitto_pub -h 127.0.0.1 -t zwavejs2mqtt/Zolder_Thermostaat/64/0/mode/set -m "{\\"value\\": 1}"'
--local ZModeHeat = 'mosquitto_pub -h 127.0.0.1 -t zwavejs2mqtt/Zolder_Thermostaat/64/0/mode/set -m "{\\"value\\": 11}"'
--local ZModeFull = 'mosquitto_pub -h 127.0.0.1 -t zwavejs2mqtt/Zolder_Thermostaat/64/0/mode/set -m "{\\"value\\": 15}"'
local ZSetHigh = 'mosquitto_pub -h 127.0.0.1 -t zwavejs2mqtt/Zolder_Thermostaat/67/0/setpoint/1/set -m "{\\"value\\": 21}"'
local ZSetLow = 'mosquitto_pub -h 127.0.0.1 -t zwavejs2mqtt/Zolder_Thermostaat/67/0/setpoint/11/set -m "{\\"value\\": 17}"'
return {
active = true,
-- active = false,
on = {
timer = { 'at 08:31',
'at 18:01' },
},
logging = {
level = domoticz.LOG_INFO,
-- level = domoticz.LOG_DEBUG,
marker = 'ZT'
},
execute = function(dz, item)
dz.executeShellCommand({ command = ZSetHigh })
dz.executeShellCommand({ command = ZSetLow })
if item.trigger == 'at 08:31' then
dz.devices('Zolder Thermostaat Mode').switchSelector('Heat')
elseif item.trigger == 'at 18:01' then
dz.devices('Zolder Thermostaat Mode').switchSelector('Eco')
end
end
}
Code: Select all
local LED_SELECTORS_ID = {887, 1114} -- dummy selector to manage the LED with predefined choices:
local NODES_nodeId = { -- id in dz and relative zwave nodes
[887] = 95,
[1114] = 119
}
local RGBW_ORDER = -- animation and static color
{ [0] = {0, 0, 0, 0, 0, 0, 4},
[10] = {9}, -- Aurora
[20] = {8}, -- Rainbow
[30] = {7}, -- Storm
[40] = {6}, -- Fireplace
[50] = {10}, -- LAPD
[60] = {1}, -- Pause
[70] = {255, 255, 255, 255}, -- warm white !!!!
[80] = {255, 165, 0, 50}, -- candle / bougie
[90] = {238, 130, 238, 0}, -- violet
[100] = {130, 65, 245, 0}, -- indigo
[110] = {0, 0, 255, 0}, -- bleu
[120] = {0, 128, 0, 0}, -- vert
[130] = {255, 255, 0, 0}, -- jaune
[140] = {255, 70, 0, 0}, -- orange
[150] = {255, 0, 0, 0}, -- rouge
[160] = {227, 137, 7, 251} -- candle white
}
-- static color
-- setColor(r, g, b, ww):
-- r: Red level: 0-255
-- g: Green level: 0-255
-- b: Blue level: 0-255
-- ww: Warm white level: 0-255
-- zwavejs2mqtt
local mqtt_prefix = "zwave"
local NODE_nodeId
return {
logging = { level =
--domoticz.LOG_ERROR, --select one to override system log level normal = LOG_ERROR
domoticz.LOG_DEBUG,
--domoticz.LOG_INFO,
--domoticz.LOG_ERROR,
--domoticz.LOG_FORCE
},
on = {
devices = LED_SELECTORS_ID,
},
execute = function(dz, device)
_G.logMarker = dz.moduleLabel -- set logmarker to scriptname
--local LOG_LEVEL = dz.LOG_INFO -- LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE - normal = LOG_INFO
local LOG_LEVEL = dz.LOG_DEBUG
dz.log("LED_SELECTOR " .. device.state .. " " .. tostring(device.level) .. " nValue: " .. device.nValue, LOG_LEVEL)
-----< BEG FUNCTIONS > ----------------------------------------------------------------------------------------
local function logWrite(str, level) -- Support function for shorthand debug log statements
if level == nil then
level = LOG_LEVEL
end
dz.log(tostring(str), level)
end
local function setZwavejs(p_NODE_commandClass, p_NODE_endpoint, p_NODE_property, p_NODE_value)
local suffix = "set"
local mqttTopic = mqtt_prefix .. '/' .. NODE_nodeId .. '/' .. p_NODE_commandClass .. '/' .. p_NODE_endpoint .. '/' .. p_NODE_property .. '/' .. suffix
local mosquitto_cmd = 'mosquitto_pub' ..' -t '.. mqttTopic .. ' -m '.. p_NODE_value
os.execute (mosquitto_cmd)
logWrite("mosquitto_cmd=" .. mosquitto_cmd)
end
local function RGBWAnimation(p_rgbAnimation)
dz.log("RGBWAnimation " .. p_rgbAnimation, LOG_LEVEL)
local NODE_commandClass = 112
local NODE_endpoint = 0
local NODE_property = 72
local NODE_value = p_rgbAnimation
setZwavejs(NODE_commandClass, NODE_endpoint, NODE_property, NODE_value)
end
local function RGBWColor (p_red, p_green, p_blue, p_warmWhite)
dz.log("RGBWColor " .. p_red .. ' '.. p_green .. ' '.. p_blue .. ' ' .. p_warmWhite, LOG_LEVEL)
local NODE_commandClass = 51
local NODE_endpoint = 0
local NODE_property = 'targetColor'
local NODE_value = '{\\"value\\":{\\"warmWhite\\":' .. p_warmWhite .. ',\\"red\\":' .. p_red .. ',\\"green\\":' .. p_green .. ',\\"blue\\":' .. p_blue .. '}}'
setZwavejs(NODE_commandClass, NODE_endpoint, NODE_property, NODE_value)
end
-----< END FUNCTIONS > ----------------------------------------------------------------------------------------
logWrite(device.id .. ' ' .. device.level)
local devLevel = device.level
if device.level == 0 or device.nValue == 0 then
device.switchSelector(0).silent()
device.switchOff().silent()
devLevel = 0
end
if devLevel ~= 170 then
NODE_nodeId = NODES_nodeId[device.id]
logWrite('NODE_nodeId: ' .. NODE_nodeId)
local paramArray = RGBW_ORDER[devLevel]
if paramArray[1] == nil then
logWrite('Level: ' .. devLevel .. ' bad parameters', dz.LOG_ERROR)
elseif paramArray[2] == nil then -- animation
RGBWAnimation(paramArray[1])
else
RGBWColor (paramArray[1], paramArray[2], paramArray[3], paramArray[4])
end
end
end
}
https://zwave-js.github.io/zwavejs2mqtt ... stant-mqttBTW as explained in docs I don't have any plan right now to keep mqtt discovery updated
so, I'm a bit surprised that the solution described here is presented as a future for zwave in domoticz, perhaps I've missed something, or a plan is ongoing...The preferred method of integrating your Z-Wave components with Home Assistant is through the official Home Assistant Z-Wave JS integration, this because MQTT Discovery is limited compared to a native integration and Home Assistant updates frequently break it. Based on this I would NOT RECCOMMEND using MQTT Discovery, I don't plan to keep it maintained in the future.
Define future...hestia wrote: ↑Thursday 09 December 2021 9:36 Hi,
I've just had a discussion on the zwave-js / zwavejs2mqtt git and as a reply:https://zwave-js.github.io/zwavejs2mqtt ... stant-mqttBTW as explained in docs I don't have any plan right now to keep mqtt discovery updatedso, I'm a bit surprised that the solution described here is presented as a future for zwave in domoticz, perhaps I've missed something, or a plan is ongoing...The preferred method of integrating your Z-Wave components with Home Assistant is through the official Home Assistant Z-Wave JS integration, this because MQTT Discovery is limited compared to a native integration and Home Assistant updates frequently break it. Based on this I would NOT RECCOMMEND using MQTT Discovery, I don't plan to keep it maintained in the future.
This is in comparison with the HomeAssistat addon integration so is all about HomeAssistant I think.
Just wondering how having it in Nodered would help with the integration into Domoticz?EddyG wrote: ↑Thursday 09 December 2021 18:39 I wonder if someone has experience with https://github.com/zwave-js/node-red-contrib-zwave-js
The backend is Zwave-js API and towards Domoticz I have full control.
If you're aware of this, I'm half reassured!heggink wrote: ↑Thursday 09 December 2021 17:54 Define future...
The thing is that OZW is pretty much a dead end street. Zwavejs is a much more workable and future proof solution. zwavejs2mqtt is based on zwavejs ('just' adds mqtt). The question then is "what's the most workable integration for domoticz". Zigbee2mqtt and zwavejs2mqtt both (still) support mqtt autodiscovery and only zwavejs2mqtt has announced that the developer has no plans to keep it maintained in the future but that does not mean that it's desupported. Zigbee2mqtt will continue to support mqtt so no problems there.
So then what? 2 options AFAICT:
- either "someone" implements native zwavejs integration into domoticz
Ultimately, this being open source, it all comes down to someone taking ownership for this hence my remark "define future". As long as this is open source, we all are responsible for keeping things maintained. Either that or we all switch to Home Assistant
- or "someone" takes over the mqtt side of zwavejs to keep it supported