Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Search the Community

Showing results for tags 'check open door/window'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • FIBARO Community
    • FIBARO Portal and Forum policy
    • FIBARO
    • Say hello!
    • Off-topics
  • FIBARO Update
    • FIBARO System Update
    • FIBARO Mobile Update
  • FIBARO Community Support
    • Scenes and Interface
    • FIBARO Products
    • FIBARO Mobile
    • FIBARO HomeKit
    • FIBARO Assistant Integrations
    • Other Devices / Third-party devices
    • Tutorials and Guides
    • Home Automation
    • Suggestions
  • FIBARO Społeczność
    • FIBARO
    • Przywitaj się!
    • Off-topic
  • FIBARO Aktualizacja
    • FIBARO System Aktualizacja
    • FIBARO Mobile Aktualizacja
  • FIBARO Wsparcie Społeczności
    • Sceny i Interfejs
    • FIBARO Urządzenia
    • FIBARO Mobilnie
    • FIBARO HomeKit
    • Integracja z Amazon Alexa i Google Home
    • Urządzenia Firm Trzecich
    • Poradniki
    • Automatyka Domowa
    • Sugestie

Categories

  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Google+


Skype


Website URL


WhatsApp


Country


Gateway/s


Interests

Found 1 result

  1. Check status of doors and windows v1.0 This simple scene will send push message every time when door or window is opened if global Variable DoorWinCheck is set to "Yes". Usage, we are sitting in garden on the opposite side of our house main entrance door. Turning this scene on and we will be informed every time when somebody opens main door If scene is started manually with RUN button or by other scene or VD then it will check all doors and windows (or just those we put in the list) and will send popup message with the list of opened doors and windows. The rest is up to you. Here is scene code: --[[ %% properties 125 value 159 value %% globals --]] --[[ --------------------------------------------- -- CHECK DOOR/WINDOWS FOR OPEN/CLOSE STATE -- --------------------------------------------- Copyright © 2016 by Zoran Sankovic - Sankotronic Version 1.0 This scene will be triggered when any door or window is opened or closed if its ID is added above in scene header %% properties section and will send you push notification which one. If it is run manually or started with RUN button or called by VD or other scene then it will check all doors and windows that are added in winDoorID table variable and send you a popup message with the list of all doors and windows openned. This scene requires following global variables: DoorWinCheck - values: "Yes", "No" - set by VD You can enter name of your variable for that purpouse and even map your values to work properly. --]] -- PART OF CODE FOR USERS TO EDIT AND SETUP --------------------------------- -- GLOBAL VARIABLES -- enter names and value mapping of your global variables -- or leave as it is and add to variables panel -- enter name of your global variable and map values local doorWinCheck = "DoorWinCheck"; local doorWinMapping = {Yes="Yes", No="No"}; -- SENSORS, USERS, NOTIFICATIONS setup -------------------------------------- -- enter in this table IDs of all window and door sensors separated by comma -- that you want to be checked when scene is started manually or by another -- scene or VD local winDoorID = {125, 159}; -- define users to send push messages, replace with your user ID local userID = {10, 204, 210}; -- flag for each user; if 1 then send notifications else if 0 do not send notifications local userFlag = {1, 1, 1}; -- setup local variables for notifications -- popup notification title local popupTitle = "Door/Window status"; -- opoup notification subtitle usually contain time when is sent local popupSubtitle = "%H:%M:%S | %d.%m.%Y."; -- message if found any door or window opened local foundOpenedMessage = "Following doors/windows are open:"; -- message if found all doors/windows closed local foundAllClosedMessage = "All doors/windows are closed!"; -- text for button to close popup notification local buttonCaption = "OK"; -- url path to icon to show on popup message local imgUrl = "" -- DEBUGGING VARIABLES --------------------------------------------------- -- setup debugging, true is turned on, false turned off. local deBug = true; -- DEFINE FLAGS - in this section add code to change users flags ----------------- -- END OF CODE PART FOR USERS TO EDIT AND SETUP -------------------------- -- BELLOW CODE NO NEED TO MODIFY BY USER --------------------------------- local OpenWinDoor = ""; local opened = false; local sourceTrigger = fibaro:getSourceTrigger(); local doorWin = fibaro:getGlobalValue(doorWinCheck); -- send push notifications! function sendPush(message) if #userID > 0 then for i = 1, #userID do if userFlag[i] == 1 then fibaro:call(userID[i], "sendPush", message); -- Send message to flagged users end end end end function sendPopup(open, Info) if open then typeInfo = "Warning"; titleInfo = foundOpenedMessage; else typeInfo = "Success"; titleInfo = foundAllClosedMessage; end ------------------------------------- POPUP MESSAGE HomeCenter.PopupService.publish({ -- title (required) title = popupTitle, -- subtitle(optional), e.g. time and date of the pop-up call subtitle = os.date(popupSubtitle), -- content header (optional) contentTitle = titleInfo, -- content (required) contentBody = Info, -- notification image (assigned from the variable) img = "", -- type of the pop-up type = typeInfo, -- buttons definition buttons = { { caption = buttonCaption, sceneId = 0 } } }) end if (sourceTrigger["type"] == "property") then if (doorWin == doorWinMapping.Yes) then local WinDoorID = tonumber(sourceTrigger['deviceID']) local status = tonumber(fibaro:getValue(WinDoorID, "value")) if (status == 1) then local room = fibaro:getRoomNameByDeviceID(WinDoorID); local deviceName = fibaro:getName(WinDoorID); if deBug then fibaro:debug(room..' ' .. deviceName .. ' is opened.') end local pushMessage = room..' ' .. deviceName .. ' is opened.' sendPush(pushMessage); else local deviceName = fibaro:getName(WinDoorID); local room = fibaro:getRoomNameByDeviceID(WinDoorID); if deBug then fibaro:debug(room..' ' .. deviceName .. ' is closed.') end end end elseif (sourceTrigger["type"] == "other") then for i = 1, #winDoorID do if tonumber(fibaro:getValue(winDoorID[i], "value")) == 1 then opened = true; OpenWinDoor = OpenWinDoor .. fibaro:getRoomNameByDeviceID(winDoorID[i]) .." ".. fibaro:getName(winDoorID[i]) .. "\n"; if deBug then fibaro:debug("It is open: "..fibaro:getRoomNameByDeviceID(winDoorID[i]) .." ".. fibaro:getName(winDoorID[i])) end end end if not opened then OpenWinDoor = "All Closed!" end; sendPopup(opened, OpenWinDoor); end fibaro:abort(); global variable DoorWinCheck can be changed by virtual device which have one label and one button. Here is code that goes to button: local selfId = fibaro:getSelfId() -- enter name of your global variable and map values local doorWinCheck = "DoorWinCheck"; local doorWinMapping = {Yes="Yes", No="No"}; if fibaro:getGlobalValue(doorWinCheck) == doorWinMapping.Yes then fibaro:setGlobal(doorWinCheck, doorWinMapping.No) fibaro:call(selfId, "setProperty", "ui.lblDoorWinCheck.value", "No") fibaro:call(selfId, "setProperty", "currentIcon", 402); -- import icon to HC and check ID else fibaro:setGlobal(doorWinCheck, doorWinMapping.Yes) fibaro:call(selfId, "setProperty", "ui.lblDoorWinCheck.value", "Yes") fibaro:call(selfId, "setProperty", "currentIcon", 401); -- import icon to HC and check ID end And if you want you can add this code to Main loop: local selfId = fibaro:getSelfId() -- enter name of your global variable and map values local doorWinCheck = "DoorWinCheck"; local doorWinMapping = {Yes="Yes", No="No"}; if fibaro:getGlobalValue(doorWinCheck) == doorWinMapping.Yes then fibaro:call(selfId, "setProperty", "ui.lblDoorWinCheck.value", "Yes") fibaro:call(selfId, "setProperty", "currentIcon", 401); else fibaro:call(selfId, "setProperty", "ui.lblDoorWinCheck.value", "No") fibaro:call(selfId, "setProperty", "currentIcon", 402); end fibaro:sleep(3000); Don't forget to change name for label from label1 to lblDoorWinCheck or vice-versa. Here is also picture of DV and icons to use for scene and VD: EDIT : New version 1.0 with some changes for users to easier setup. Now you can use existing variable and values you just need to enter name of your variable and map your values to Yes and No for checking and sending push notification when door or window is opened. Also changed push notifications so that users are defined in table variable userID. userFlag defines if user will get notification set by 1, or not set with 0. You can add your part of code to change flags, see example: -- DEFINE FLAGS - in this section add code to change users flags ----------------- local momAway = "MomAway"; local momAwayMapping = {Yes="Yes", No="No"}; if momAway ~= "" then if fibaro:getGlobalValue(momAway) == momAwayMapping.Yes then userFlag[3] = 0; userFlag[4] = 0; end end -- END OF CODE PART FOR USERS TO EDIT AND SETUP -------------------------- Enjoy coding!
×
×
  • Create New...