Firebase Cloud Messaging & FIBARO FGMS-001 attributes  [SOLVED]

Moderator: leecollings

Post Reply
User avatar
elzorrovega
Posts: 64
Joined: Friday 08 May 2020 19:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Bordeaux, France
Contact:

Firebase Cloud Messaging & FIBARO FGMS-001 attributes  [SOLVED]

Post by elzorrovega »

Hello All,

My configuration is as follows:

• Domoticz Version 2020.2 running on Raspberry Pi 3 B+
• Aeon Labs Z‐Stick Gen5 (Z‐Wave USB Adapter00)
• Aeon Labs Siren Gen5 (Z-Wave Siren Gen5)
• FIBARO DOOR/WINDOW SENSOR 2 FGDW-002
• FIBARO MOTION SENSOR FGMS-001-FR-A-V1.01
• FIBARO WALL PLUG FGWP-102
• Zipato MINI KEYPAD RFiD/Z-WAVE
• Domoticz app on iOS


After some help and some tweaking please find a script which I made to both notify and adjust Fibaro Motion Sensor parameters when at home. These parameters are not accessible with standard dzVents commands. The idea is to save battery life. Furthermore, if you wish to use FCM (Firebase Cloud Messaging) please do not forget to enable GMC on the Setting; Notification page of your Domoticz Server.

Your smartphone must also be registered in the Mobile Devices Setup page. I am using Domoticz on iOS. By no means, do I endorse it; however, it seems that if you wish to get notifications you must have the paid version. Toggle the notification switch in the iOS app to register your phone in Domoticz Server. It took some research to find this little trick.

I am playing with the eighth and ninth parameters to "blind" devices when someone is at home. The script changes the eight parameter using a JSON command; Domoticz time and Security Panel Setting.
Please be aware that the device setting will be updated once the device wakes-up. In my particular case the Wake-up interval is 30 minutes. I will follow the battery life and find the compromise between a "blind" device and waking-up the device more often...

Hope it's of use to someone else. ElZorroVega :D

Code: Select all

-- El Zorro
-- 23/05/2020
-- Notify Security Panel Status
-- Set PIR mode to as a function of time or if alarm is set.
--      PIR always active
--      PIR sensor active during the night only 
--      PIR sensor active during the day only
-- Trying to save motion sensor's battery life 
--
return {
	on = {
	    timer = {            
	        'at sunset',                -- uses sunset/sunrise info from Domoticz
            'at sunrise',
            },
		security = {
			domoticz.SECURITY_ARMEDAWAY,
			domoticz.SECURITY_ARMEDHOME,
			domoticz.SECURITY_DISARMED
		}
	},
	execute = function(domoticz, item)
-- Block Definitions
        local securityArmed = ( domoticz.security == domoticz.SECURITY_ARMEDAWAY) -- Is Alarm away set?
        local securityArmedHome = ( domoticz.security == domoticz.SECURITY_ARMEDHOME) -- Is Alarm home set?
        local securityDisarmed = ( domoticz.security == domoticz.SECURITY_DISARMED) -- Is Alarm disarmed?
        local now = domoticz.time
        local Time = require('Time')
        local min2sunrise = now.sunriseInMinutes -- since midnight
        local min2sunset = now.sunsetInMinutes -- since midnight
        local midnight = Time(now.rawDate .. ' 00:00:00')
        local sunrise = midnight.addMinutes(min2sunrise)
        local sunset = midnight.addMinutes(min2sunset)
--
     	if (securityArmed == true) then
            -- Hall PIR always active when ARMEDAWAY
            domoticz.openURL('http://192.168.1.30:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=5&valuelist=1_MTA%3D_8_UElSIHNlbnNvciBhbHdheXMgYWN0aXZl_')
            domoticz.log('HALL PIR always active JSON message sent')
            -- Living PIR always active when ARMEDAWAY
            domoticz.openURL('http://192.168.1.30:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=6&valuelist=1_MTA%3D_8_UElSIHNlbnNvciBhbHdheXMgYWN0aXZl_')
            domoticz.log('LIVING PIR always active JSON message sent')
            if (item.isSecurity) then -- Send Notifications to various mobile devices
                domoticz.notify('DomoticzVents', 'ARMEDAWAY set', domoticz.PRIORITY_HIGH, '', 'midx_1', domoticz.NSS_FIREBASE)
                domoticz.notify('DomoticzVents', 'ARMEDAWAY set', domoticz.PRIORITY_HIGH, '', 'midx_2', domoticz.NSS_FIREBASE)
                domoticz.notify('DomoticzVents', 'ARMEDAWAY set', domoticz.PRIORITY_HIGH, '', 'midx_3', domoticz.NSS_FIREBASE)
                domoticz.notify('DomoticzVents', 'ARMEDAWAY set', domoticz.PRIORITY_HIGH, '', 'midx_4', domoticz.NSS_FIREBASE)
            end
--
        elseif (securityArmedHome == true) then
             -- Hall PIR always active when ARMEDAWAY
            domoticz.openURL('http://192.168.1.30:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=5&valuelist=1_MTA%3D_8_UElSIHNlbnNvciBhbHdheXMgYWN0aXZl_')
            domoticz.log('HALL PIR always active JSON message sent')
            -- Living PIR always active when ARMEDAWAY
            domoticz.openURL('http://192.168.1.30:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=6&valuelist=1_MTA%3D_8_UElSIHNlbnNvciBhbHdheXMgYWN0aXZl_')
            domoticz.log('LIVING PIR always active JSON message sent')
--
            if (item.isSecurity) then -- Send Notifications to various mobile devices
                domoticz.notify('DomoticzVents', 'ARMEDHOME set', domoticz.PRIORITY_HIGH, '', 'midx_1', domoticz.NSS_FIREBASE)
                domoticz.notify('DomoticzVents', 'ARMEDHOME set', domoticz.PRIORITY_HIGH, '', 'midx_2', domoticz.NSS_FIREBASE)
                domoticz.notify('DomoticzVents', 'ARMEDHOME set', domoticz.PRIORITY_HIGH, '', 'midx_3', domoticz.NSS_FIREBASE)
                domoticz.notify('DomoticzVents', 'ARMEDHOME set', domoticz.PRIORITY_HIGH, '', 'midx_4', domoticz.NSS_FIREBASE)
            end
--
        elseif (securityDisarmed == true) then
            if (item.isSecurity) then -- Send Notifications to various mobile devices
                domoticz.notify('DomoticzVents', 'DISARMED set', domoticz.PRIORITY_HIGH, '', 'midx_1', domoticz.NSS_FIREBASE)
                domoticz.notify('DomoticzVents', 'DISARMED set', domoticz.PRIORITY_HIGH, '', 'midx_2', domoticz.NSS_FIREBASE)
                domoticz.notify('DomoticzVents', 'DISARMED set', domoticz.PRIORITY_HIGH, '', 'midx_3', domoticz.NSS_FIREBASE)
                domoticz.notify('DomoticzVents', 'DISARMED set', domoticz.PRIORITY_HIGH, '', 'midx_4', domoticz.NSS_FIREBASE)
            end
            -- Set PIR Detection Mode as a function of time. 
            -- We are in the daytime, if sunrise is equal to now or now is after sunrise and now is before sunset.
            --
            print('Date ' .. now.raw)
            if now.compare(sunrise).compare <= 0 and now.compare(sunset).compare == 1 then
                print('Sunrise @ ' .. sunrise.time )
                print('Daytime ' .. now.compare(sunrise).compare)
                -- Hall PIR sensor active during the night only
                domoticz.openURL('http://192.168.1.30:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=5&valuelist=1_MTA%3D_8_UElSIHNlbnNvciBhY3RpdmUgZHVyaW5nIHRoZSBuaWdodCBvbmx5_')
                domoticz.log('Hall PIR sensor active during the night only JSON message sent')
                -- Living PIR sensor active during the night only
                domoticz.openURL('http://192.168.1.30:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=6&valuelist=1_MTA%3D_8_UElSIHNlbnNvciBhY3RpdmUgZHVyaW5nIHRoZSBuaWdodCBvbmx5_')
                domoticz.log('Living PIR sensor active during the night only JSON message sent')
            else
                print('Sunset @ ' .. sunset.time)
                print('Nightime ' .. now.compare(sunset).compare)
                -- Hall PIR sensor active during the day only
                domoticz.openURL('http://192.168.1.30:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=5&valuelist=1_MTA%3D_8_UElSIHNlbnNvciBhY3RpdmUgZHVyaW5nIHRoZSBkYXkgb25seQ%3D%3D_')
                domoticz.log('Hall PIR sensor active during the day only JSON message sent')
                -- Living PIR sensor active during the day only
                domoticz.openURL('http://192.168.1.30:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=6&valuelist=1_MTA%3D_8_UElSIHNlbnNvciBhY3RpdmUgZHVyaW5nIHRoZSBkYXkgb25seQ%3D%3D_')
                domoticz.log('Living PIR sensor active during the day only JSON message sent')                     
            
            end
         end
	end
}
Image
Image
Image
Attachments
Notification_Settings.png
Notification_Settings.png (76.28 KiB) Viewed 1526 times
mobile_device.png
mobile_device.png (74.58 KiB) Viewed 1526 times
fibaro_par.png
fibaro_par.png (32.68 KiB) Viewed 1526 times
The solution to the problem changes the problem!

Rasberry Pi 4 Model B; Bullseye -64 bit OS 6.1.21-v8+ #1642
Domoticz Version: 2024.7
zwave-js-ui: 9.30.1.46a9eda
zwave-js: 14.3.8
home id: 3714679688
home hex: 0xdd698388*
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest