I would like to share my integration of am43 roller blinds.
#Prerequisites:
1) Proper setup of https://github.com/TheBazeman/A-OK-AM43-Blinds-Drive
Hints:
I have added every blind in separete group. You need to remember to make proper naming. It is not clear in instruction
Code: Select all
[AM43_BLE_Devices]
Blinds1=xx:xx:xx:xx:xx:xx
Blinds2=yy:yy:yy:yy:yy:yy
[blind1]
Blinds1=xx:xx:xx:xx:xx:xx
[blind2]
Blinds2=yy:yy:yy:yy:yy:yy
You need to have one with dzvents 3.0.4 on newer. In stable release it is 3.0.2 and my script will not work.
You can install any newer beta or compile it by yourself (I did it) with commit https://github.com/domoticz/domoticz/co ... d2832ddfda
you can follow this instruction
https://www.domoticz.com/wiki/Build_Dom ... rom_source
and before compiling domoticz execute command:
Code: Select all
git checkout acdcbb2f00f4966763a3cf2b8aac4bd2832ddfda
3) I had to change port on A-OK-AM43-Blinds-Drive server as it was conflicted with octoprint and hosted on different machine then domoticz
to do that in file AOK-AM43.py
Code: Select all
if __name__ == "__main__":
os.system('clear') # Clear screen
app.run(host='0.0.0.0', port=5001) #Listen to all interfaces ,debug=True
#Integration
4) Then create switch and change type to Blinds Percentage and Lux for each blind.
5) Script for steering the blinds
Code: Select all
local lewaroleta = 'Rollerblind 1'
local prawaroleta = 'Rollerblind 2'
return {
on = {
devices = {lewaroleta, prawaroleta},
},
execute = function(domoticz, triggeredItem)
if (domoticz.devices(lewaroleta).changed)
then
if (domoticz.devices(lewaroleta).level <100 and domoticz.devices(lewaroleta).level > 0)
then
domoticz.openURL('http://IP:5001/AM43BlindsAction/'..domoticz.devices(lewaroleta).level..'/blind1')
end
if (domoticz.devices(lewaroleta).state == 'Open')
then
domoticz.openURL('http://IP:5001/AM43BlindsAction/Open/blind1')
end
if (domoticz.devices(lewaroleta).state == 'Closed')
then
domoticz.openURL('http://IP:5001/AM43BlindsAction/Close/blind1')
end
end
if (domoticz.devices(prawaroleta).changed)
then
if (domoticz.devices(prawaroleta).level <100 and domoticz.devices(prawaroleta).level > 0)
then
domoticz.openURL('http://IP:5001/AM43BlindsAction/'..domoticz.devices(prawaroleta).level..'/blind2')
end
if (domoticz.devices(prawaroleta).state == 'Open')
then
domoticz.openURL('http://IP:5001/AM43BlindsAction/Open/blind2')
end
if (domoticz.devices(prawaroleta).state == 'Closed')
then
domoticz.openURL('http://IP:5001/AM43BlindsAction/Close/blind2')
end
end
end
}
Code: Select all
local przycisk = 'testpobrania'
local lewaroleta = 'blind 1'
local prawaroleta = 'blind 2'
local lewaroletalux = 'blind 1 Lux'
local prawaroletalux = 'blind 2 Lux'
return {
on = {
timer = {
'every hour' -- 00:00, 01:00, ..., 23:00 (24x per 24hrs)
},
devices = {przycisk},
httpResponses = {
'stanrolet' -- must match with the callback passed to the openURL command
}
},
execute = function(domoticz, item, device)
if (item.isTimer or item.isDevice and item.active ) then
domoticz.openURL({
url = 'http://IP:5001/AM43BlindsAction/CheckStatus',
method = 'GET',
callback = 'stanrolet', -- see httpResponses above.
})
end
if (item.isHTTPResponse) then
if (item.ok) then
if (item.isJSON) then
if (item.json.status=='OK')
then
domoticz.openURL('http://127.0.0.1:8081/json.htm?type=command¶m=udevice&idx='..domoticz.devices(prawaroletalux).idx..'&svalue='..item.json.Blinds2[1].light..'&battery='..item.json.Blinds2[1].battery)
domoticz.openURL('http://127.0.0.1:8081/json.htm?type=command¶m=udevice&idx='..domoticz.devices(lewaroletalux).idx..'&svalue='..item.json.Blinds1[1].light..'&battery='..item.json.Blinds1[1].battery)
domoticz.devices(lewaroleta).setLevel(item.json.Blinds1[1].position)
domoticz.devices(prawaroleta).setLevel(item.json.Blinds2[1].position)
end
else
print(item.data)
end
else
domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
end
}
I used deconz integration.
Code: Select all
local przycisk1 = 'button 1'
local przycisk2 = 'button 2'
local lewa = 'blind 1'
local prawa = 'blind 2'
return {
on = {
devices = {
przycisk1,przycisk2
}
},
execute = function(domoticz, device)
if(domoticz.devices(przycisk1).changed or domoticz.devices(przycisk2).changed)
then
if(domoticz.devices(przycisk1).levelName=='B3' or domoticz.devices(przycisk2).levelName=='B3')
then
domoticz.devices(lewa).setLevel(70)
domoticz.devices(prawa).setLevel(70)
end
if(domoticz.devices(przycisk1).levelName=='B1' or domoticz.devices(przycisk2).levelName=='B1')
then
domoticz.devices(lewa).switchOn()
domoticz.devices(prawa).switchOn()
end
if(domoticz.devices(przycisk1).levelName=='B2' or domoticz.devices(przycisk2).levelName=='B2')
then
domoticz.devices(lewa).switchOff()
domoticz.devices(prawa).switchOff()
end
end
end
}