Hi!
First post and HA-newbie so be nice
Running Home Assistant OS.
So I’m a longtime Open Z-Wave and Domoticz user that finally decided to give HA a try. While I do love how beautiful and easy HA is to use, I’ve always figured that the “plugin”-way and “easyness” comes at a price of increased limitations of how I can program and control what happens. This can be pure ignorence on my part, however.
I’m currently trying to both migrate my devices and also my automations but find the “automations” lacking in the sense that you essentially write configurations rather that code, logic or scripts.
Please advice if / how the following can be acheived in Home Assistant:
I want to automatically change the value of a parameter of all Z-wave devices of one or many types. I also want to do this “dynamically” in the sense that I dont want to update or maintain a configuration-file whenever I add or remove a device of that same type to the network. (Here I currently feel that “automations” lack a bit - it’s not really an “automation” if I have to manually maintain a configuration file imo)
In Domoticz I currently solve this by utilizing it’s web API. Whenever a trigger occurs (my case, change in electricity price) I query all the Z-Wave devices currently in Domoticz. I then store the Z-wave Device Id for all devices that have a certain type. In the next API call I set the desiered parameter to the desiered value for all those Device Ids.
Quite simple and straight forward - this way I dont have to create or update “automations” every time I add another Z-wave device to the network. How can the same be achieved in Home Assistant?
To maybe further clarify what I want to do, heres the important parts of my current LUA-script in Domoticz:
A potential solution does in no way have to be in LUA, pretty much any other programming or scripting language / syntax is preferred. LUA is just the prefered language for Domoticz automations.
-- Variables to keep track of what Z-wave Device Type script should handle "dynamically"
local wallplugProductTypeId = '0x0602'
local dimmerProductTypeId = '0x1c01'
local switchProductTypeId = '0x1b01'
local function getDevices(domoticz) -- Get _all_ Zwave Devices
domoticz.openURL({
url = 'https://localhost:8080/json.htm?type=openzwavenodes&idx=2',
method = 'GET',
callback = 'getZwaveDevices'
})
end
local function getDeviceInfo(jsonData) -- Filter out the device types we want and store its Ids in tables
local deviceCount = getTableLength(jsonData.result)
local wallplugIds = {}
local dimmerIds = {}
local switchIds = {}
for i = 1,deviceCount,1
do
local device = jsonData.result[i]
if (device.Product_type == wallplugProductTypeId) then
table.insert(wallplugIds,device.idx)
elseif (device.Product_type == dimmerProductTypeId) then
table.insert(dimmerIds,device.idx)
elseif (device.Product_type == switchProductTypeId) then
table.insert(switchIds,device.idx)
end
end
return wallplugIds, dimmerIds, switchIds
end
local function setWallplugColor(domoticz, id, color) -- Change Zwave parameter 41 to the value of 'color' for the given Ids
domoticz.openURL({
url = 'https://localhost:8080/json.htm?type=command¶m=applyzwavenodeconfig&idx='.. id ..'&valuelist=41_' .. color,
method = 'GET'
})
end