Page 1 of 1

am43 roller blinds integration with domoticz.

Posted: Monday 12 April 2021 23:48
by greenwitch
Hello,

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
2) Proper version of domoticz.
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
With 2021 stable release problem does not exist any more.
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
}
6) Script for checking status with button if you want to update manually and of course every hour - timer can be adapted. You need to create dummy switch and change it to pushon button.

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&param=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&param=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
}

7) final script is for button ( xiaomi double switch - https://www.aliexpress.com/item/1005001 ... web201603_ )
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
}
Good luck :-)

Re: am43 roller blinds integration with domoticz.

Posted: Friday 11 June 2021 15:49
by jon205
How is this working for you? For me the results were quite inconsistent. My experience is that the bluetooth connection isn't working all the time. I haven't tried your setup, but it wasn't quite as stable as I hoped.

Re: am43 roller blinds integration with domoticz.

Posted: Thursday 01 July 2021 12:10
by greenwitch
I have purchased external bluetooth dongle and it is working perfect.
I have purchased two additional (I will have 4 in total) and I will let you know if it is still stable.
I think it is cheapest working solution for smart roller blinds (I paid 33USD per piece two weeks ago)

Re: am43 roller blinds integration with domoticz.

Posted: Wednesday 07 July 2021 11:28
by jon205
I've bought an external bluetooth dongle as well. It's even a 'long range' version. I've given up and I'm just using the proprietary app on the phone. That wasn't the idea behind this when I bought the motors though.

Re: am43 roller blinds integration with domoticz.

Posted: Thursday 26 August 2021 11:34
by greenwitch
I have integrated two additional roller blinds and still everything is working perfectly.
Next step is to prepare some voltage stabilizer to reuse solar panels for charging the batteries and not only for lux detection.

Re: am43 roller blinds integration with domoticz.

Posted: Monday 30 August 2021 0:01
by roblom
Original I think the solar panel was intended to charge the battery but for some reason it doesn't work. Hope you find the problem..