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 'events'.
-
Geofence looks broken - events as scene triggers [HC2]
kevgeniy posted a question in Scenes and Interface
Hello! I have HC2 v4.590 and suffer over the user arrive and leave scenes which allow to determine home area entering or leaving by event GeofenceEvent. This event never triggers. Tried to leave and enter home perimeter which set in Localization panel for that location many times. So I've added "Location" property scene trigger. Of course, I have Fibaro app 1.27.0.0 installed and running on my Samsung S9+ (Android 10), all requested app permissions are given, phone ID in Lua scene is correct and location ID is correct too - checked many times. Could anybody tell me what's wrong? Scene code is: --[[ %% properties 2 Location %% events 379 GeofenceEvent 4 %% globals --]] local adminUserId = 2; local homeLocation = "XX.ZZZZZZ;YY.NNNNNN"; local startSource = fibaro:getSourceTrigger(); local userAdminPosition = fibaro:getValue(adminUserId, "Location"); local userAdminDistance = tonumber(fibaro:calculateDistance(userAdminPosition, homeLocation)); local isUserAdminHome = fibaro:getGlobalValue("UserAdminAtHome"); local homePerimeter = tonumber(fibaro:getGlobalValue("HomePerimeter")); fibaro:debug(json.encode(startSource)); fibaro:debug("---------------------------------------------------------------"); fibaro:debug(os.date("%a, %d.%m") .. " - " .. tostring(math.floor(userAdminDistance)) .. " m (perimeter " .. homePerimeter .. " m), Admin @home - ".. isUserAdminHome); fibaro:debug("=============================================="); if ( ( (userAdminDistance <= homePerimeter or (startSource["type"] == "event" and startSource.event["type"] == "GeofenceEvent" and startSource.event.data["geofenceAction"] == "enter") ) and isUserAdminHome == "no" ) or startSource["type"] == "other" ) then fibaro:startScene(231); -- run Admin Home scene end Outcoming log is: -
Fibaro Smart Home Event Announcements on Google Home
drasisautomation posted a question in Google Assistant
Hello! I have made a small video guide showing a way to announce Fibaro Smart Home events (like someone ringing a doorbell) on Google Home by using Node-Red in between. Might be useful to people who are looking for things like this. Video Link: https://youtu.be/SOx9QfJgwCQ- 4 replies
-
- 1
-
- googlehome
- events
-
(and 1 more)
Tagged with:
-
Note. The first ~2000 posts of this thread is mainly about EventRunner3 that is for the HC2. EventRunner3 is not developed further, but bugs are fixed as they are reported. For HC3, the version is EventRunner4, and is a QuickApp,. Here is a post introducing EventRunner4. Its EventRunner5, link <here> Most of the 'Event Script" syntax and commands are still valid and old posts can be of use for new HC3 owners. Link to EventRunner3.lua for the HC2 There is a QA that is used to download and install the EventRunner4 QA to your HC3 (and update to new versions) Here is an example of how to code in a "single instance / event" style. A style I'm using today for all of my scenes. The idea is that instead of having to deal with a new instance being spawned with every scene trigger, all triggers are dealt with from within a single scene instance that is continuously running. It becomes something close to a traditional event loop model found in most modern GUI frameworks. The advantages with coding scenes in this style are: Scene can keep state in local lua variables between scene invocations/triggers Easy to keep different rules/logic in the same scene without causing conflicts, e.g. combining continuous running loops/schedules with immediate reaction on incoming triggers Easy to distribute different rules/logic between different scenes and allow them to communicate Easy to schedule actions to do in the future - that can be easily cancelled if new information is gained. Because the scene is continuously running it doesn't matter if there is a heavy initialisation when the scene starts up (parsing HomeTables etc.) as it is only done once... The framework has extensive support to run and debug the scene offline on a PC/Mac to get things right before deploying the scene on the HC2 (uses HC2 emulator). Offline it is easy to simulate trigger/events to understand if the logic is correct, something that is not always easy to detect in a asynchronous environment. It has publish/subscribe mechanism allowing scenes to exchange events without having to know each other's names or IDs or rely on global variables. It has proven to be easy to integrate with external event/msg based systems like Node-red, where scenes can both send and receive events to node-red and thus extend functionality with Alexa, Google home, Hue etc etc. The framework is available in two version, a 'light' version and a full blow version with a lot of bells and whistles. The latter also supports writing rules in EventScript, a "simple", but very flexible and efficient approach to writing rules that need to trigger things at various times of the day, or trigger on sensors or switches changing states. The implementation of EventScript is built on-top of the single instance framework and the event model and would have been impossible to do in a traditional scene model. Ex of EventScript rules. --[[ %% properties 54 value 55 value 56 value 57 value 66 value 77 value 78 sceneActivation 88 ui.Slider1.value 88 ui.Label1.value %% events 100 CentralSceneEvent 120 AccessControlEvent %% globals Home %% autostart --]] myLightSensor1 = 54 -- do not declare local, script will not find them(!) myLightSensor2 = 55 myMotionSensor1 = 56 myMotionSensor2 = 57 myLight1 = 66 myLight2 = 67 myDoorSensor = 77 mySwitch = 78 myVD=88 myKeyFob = 100 myLock = 120 function main() -- Trigger rules Rule.eval("myLightSensor1:lux > 200 => myLight1:on") -- Turn on light1 if lux value goes above 200 Rule.eval("myLight1:isOn => myLight2:on") -- Turn on light2 if light1 is turned on Rule.eval("myDoorSensor:breached => myLight1:on") -- Turn on light1 if door sensor is breached Rule.eval("mySwitch:scene == S2.click => myLight1:on") -- Turn on light1 if S2 is clicked once Rule.eval("slider(myVD,'Slider1') == 50 => myLight1:on") -- Turn on light1 if slider is set to 50 Rule.eval("label(myVD,'Label1') == 'ON' => myLight1:on") -- Turn on light1 if label is set to 'ON' Rule.eval("myKeyFob:central.keyId==4 => myLight1:on") -- Turn on light1 if key 4 is pressed on keyFob Rule.eval("myLock:access.status=='Unlock' => log('Door unlocked by %s',myLock:access.name)") -- Door unlocked Rule.eval("$Home == 'AWAY' => myLight1:on") -- Turn on light1 if fibaro global variable 'Home' is set to 'AWAY' Rule.eval("#AccessControlEvent{data={name='$name',slotId='$slot',status='Unlock',id=myLock}} => log('Door unlocked by %s',name)") -- more rules -- Turn on lamp at 15min before sunset Rule.eval("@sunset-00:15 => myLight1:on") -- Turn on 2 lamps 15min past sunrise on weekdays Rule.eval("@sunrise+00:15 & wday('mon-fri') => {myLight1,myLight2}:on") -- Turn on lamp if sensor breached Rule.eval("myMotionSensor1:breached => myLight1:on") -- Turn off lamp if sensor safe for 5min Rule.eval("trueFor(00:05,myMotionSensor1:safe) => myLight1:off") -- Turn on lamp if doubleclick on switch S2 Rule.eval("mySwitch:scene==S2.double => myLight1:on") -- Toggle lamp if key '1' pressed on keyfob Rule.eval("myKeyfob:central.keyId=='1' => myLight1:toggle") -- Turn on lamp if average lux is less than 200 Rule.eval("sum({myLightSensor1,myLightSensor2}:lux)/2<200 => myLight1:on") -- Turn on lamp if any of motion sensor myMotionSensor1,myMotionSensor2 are breached Rule.eval("{myMotionSensor1,myMotionSensor2}:breached => lamp:on") -- ..and turn off lamp all motion sensors are safe for 10min Rule.eval("trueFor(00:10,{myMotionSensor1,myMotionSensor2}:safe) => lamp:off") -- Turn on lamp if any of motion sensor myMotionSensor1,myMotionSensor2 is breached -- but not if it's daytime, and only at dimmed level during night Rule.eval([[{myMotionSensor1,myMotionSensor2}:breached => || 24:00..sunrise >> myLight1:value=30 || sunset-00:30..24:00 >> myLight1:on ]]) end More on EventScript and the full blown version is available in the posts listed below: Here is a post on setting up the framework (works for EventRunnerLite too) Here is a post on the EventRunnerLite version - a bare bone version of the framework Here is a post on writing schedulers using EventScript. Here is a post on writing trigger rules using EventScript. Here is a post on EventScript syntax and rules (here is a new version under development) Here is a post on writing Lua event handlers Here is a post on debugging the framework Here is a post on the publish/subscribe mechanism Here is a post on enabling Hue support - mapping of Hue devices to standards z-wave/fibaro:* calls Here is a post on integrating the event model with Node-red - sending/receiving events from node-red, with extendable, example flow. Gives support for Sonos TTS and Alexa input...Updated flow <here>. (and here is another thread, 1,2,.) Here is a thread on the HC2 emulator used to debug EventRunner offline Here is a post on creating VDs from an ER scene and handle the VD logic with EventScript rules (and a calculator example) There will also be some services based on the EventFramework posted iOSLocator - a service that checks with iClod for people at places and sends events to other EventFramework services iCalendar - a service that fetches evens from Apple's iCloud calendar or Google calendar and post them to scenes. (latest iCalendar) Logger service - part of Supervisor Alarm service - TBD CronRunner - a UNIX like crontab service other scenes can register call-backs with Supervisor - A scene that pings EventRunner scenes and makes sure they stay alive. Best practices rules - TBD Implementation notes Notes on the basic EventRunner framework Notes on the EventScript implementation - TBD ChangeLog for the EventRunner framework. The lastest version of the code is kept in my GitHub. The background of this framework and a thread discussing it can be found here, however the code has evolved a bit from when originally posted there. If you are new to EventRunner I don't encourage you to read the posts in the thread chronological, as it contains a lot of outdated information. Instead, the best way to get an understanding of the capabilities of EventRunner is to browse the links in the list above.
- 4,679 replies
-
- 11
-
- events
- rule engine
- (and 8 more)
-
Hey Guys, Just something missing that would help me with some of my issues with devices and alerts. Would be good to see some more detail in the Events Panel. It would be good to see things such as: Source of the Event (scene id and name) Filtering on events based on a scene Logins from other users