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 'hue'.
-
I have started to use this QA instead of my old ChildrenOfHue QA. My Hue integration philosophy is I use the Hue hub as the main controller as I prefer the Hue app to set&control lights + that I have other Hue integrations, like nodered. Letting the HC3 be the zigbee controller and taking over the devices is not an option for me. YahueV2.fqa v0.54 (upgradable to v0.55) So, this QA imports some of the Hue resources from the Hue hub and creates QA child devices to represent them. It supports Hue devices/resources such as door/window contact sensor Implemented as a com.fibaro.doorSensor motion sensor Implemented as a com.fibaro.motionSensor temperature sensor Implemented as a com.fibaro.temperatureSensor lux sensor Implemented as a com.fibaro.lightSensor rotary sensor Implemented as a com.fibaro.multilevelSensor. Sets the value of the sensor 0-100 when rotary is turned. args={div=4} will divide reported steps with 4 - gives a smoother turning. button dimmer/switch remote Implemented as a com.fibaro.remoteControll Sends centralSceneEvents, "Pressed","HeldDown","Released". Experimental support for double-clicks... plug Implemented as com.fibaro.binarySwitch room & zone Implemented as com.fibaro.multilevelSwitch turnOff turns on light group associated to room/zone turnOn recalls scene for light group if quickVar 'scene' is set to scene name. Otherwise, the light group is just turned on setValue sets the dimming level of the associated light group At the moment, if any light is off-line the QA will set the dead property. This way scripts can react if lights are powered off/on. It may become a configurable option... Support for leveChange commands. startLevelIncrease,startLevelDecrease,and stopLevelChange. args={dimdelay=10000} sets dim cycle (0-100%) to 10s. Some of the Hue controllers will be realised as several QAs. Ex. the 'Hue tap dial switch' is realised both as a button/remote control and a rotary sensor QA. The 'Hue motion sensor' is a temperature, motion, and lux sensor and can create 3 QAs. It even works with the Hue secure camera providing motion and lux sensor. It does not support lights directly, but it supports rooms and zones. (to represent lights using the HC3 UI and rgb/xy issues, makes it too cumbersome, and scenes/zones gives the control I need) Rooms and zones are represented as a multilevelSwitch, providing turnOn,turnOff, and set brightness/dimming turnOn/turnOff operates on the light group associated with the room/zone. If the room/zone's QA has the quickAppVariable 'scene' set to a scene associated with the room/zone the scene will be recalled when doing a turnOn. If you need the to apply different scenes, update the scene variable for the room/zone QA, before turning on. To configure what child devices to create, go into the QA file "Map" and set enabled=true for the QAs/devices to create. If you do any changes in the Hue hub, just restart the QA, the 'Map' will be updated. ...and it uses the Hue v2 api that should be more efficient as it streams the events and no need to periodically poll the hub. If you have more than one hub, install additional Yahue QAs... Setting the quickAppVariable 'update' to 'yes' will download the latest version from my GitHub while preserving configuration. Examples: Turn on a room/zone at 30min past sunset, and turn it off 60min before sunrise. (zoon/room has deviceID 1128). Set 'scene' quickVar if you want the zone/room to turnOn with a specific scene. Conditions triggers: { conditions = { { isTrigger = true, operator = "==", property = "sunset", type = "date", value = 30 }, { isTrigger = true, operator = "==", property = "sunset", type = "date", value = 360 }, { isTrigger = true, operator = "==", property = "sunrise", type = "date", value = -60 } }, operator = "any" } Actions: local time = sourceTrigger.property..":"..(sourceTrigger.value or "") local zone = 1128 if time=='sunset:30' then fibaro.call(zone,"setVariable","scene","earlyScene") -- First scene 30min after sunset fibaro.call(zone,"turnOn") elseif time=='sunset:360' then fibaro.call(zone,"setVariable","scene","lateScene") -- Second scene 3hours after sunset fibaro.call(zone,"turnOn") elseif time=='sunrise:-60' then fibaro.call(zone,"turnOff") -- Turn off in the morning end Another example. A Hue tap switch (deviceID 1596) with 4 buttons controlling 3 scenes for a zone (deviceId 1587) (+ turnOff) Conditions/triggers: { conditions = { { id = 1596, isTrigger = true, operator = "anyValue", property = "centralSceneEvent", type = "device" } }, operator = "all" } Actions: local zone = 1587 if not sourceTrigger.property == 'centralSceneEvent' then return end local key = sourceTrigger.value.keyAttribute..":"..sourceTrigger.value.keyId if key == "Released:1" then fibaro.call(zone,"setVariable","scene","Red") fibaro.call(zone,"turnOn") elseif key == "Released:2" then fibaro.call(zone,"setVariable","scene","Blue") fibaro.call(zone,"turnOn") elseif key == "Released:3" then fibaro.call(zone,"setVariable","scene","Green") fibaro.call(zone,"turnOn") elseif key == "Released:4" then fibaro.call(zone,"turnOff") end There was a bug for remotes/buttons so update to v0.53 and recreate the remote/button devices (delete them)
- 21 replies
-
- 4
-
- philips hue bridge
- hue scene
-
(and 4 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)
-
Having to reboot HC3 each day - possibly related to Hue integration?
Friso posted a question in Home Center 3
Hi All, Since a couple of weeks my HC3 has developed strange behaviour. I'm not running a big setup. It is mainly used to control lights, but it is also in use as an alarm- and fire detection system. In total I'm running 39 z-wave devices and 19 Hue lights. The first signs of problems come from the Hue integration. HC3 shows the Hue lights as available, but in fact has lost connection to the Hue hub (which has been running for a year without any problems). During the last week I've found this also affects the rest of the HC3 functionality. For instance: this morning our alarm was on, but a door was opened. Only after about 5 minutes the alarm scene started; maybe because the same door was opened again. In the meantime, a couple of lights were switched off and on without any issues. After a reboot, everything is normal again. I'm running 5.140.17 and Hue is on 1.57.1957200040 (last update, as far as I know). Anyway: I'm a bit in the dark here, so I'm turning to the vast wisdom of this forum. Thanks in advance! -
I have started to code a Hue QA that uses the new V2 api. It's still early beta... (v0.11) It's available via the QAUpdater QA. The QA is a standalone QA that keeps an updated state of the Hue resources and accept commands to change them - like turning on/off lights. It only provides an API (fibaro.call, fibaro.getValue) and no QuickAppChild devices (the latter can be built relatively easy built using HueConnector...) To use the QA you create a your own client QA that calls the HueConnector QA. Example client: local devices = { "9222ea53-37a6-4ac0-b57d-74bca1cfa23f", -- Sensor "3ab27084-d02f-44b9-bd56-70ea41163cb6", -- Tim "a007e50b-0bdd-4e48-bee0-97636d57285a", -- Switch } function QuickApp:hueInited() local function printf(...) print(string.format(...)) end -- local map = self.hue.getRsrc("deviceMap") -- Setup custom mapping from room+name to Hue ID. -- for id,info in pairs(map) do -- local name = ((info.room and (info.room.."_") or "")..info.name):gsub("[%-%s]","_") -- self.hue.idMap[name]=id -- print(name,"=>",id) -- end print(("-"):rep(40)) print("Mapping table:") -- Print out default mapping for name,id in pairs(self.hue.idMap) do printf("'%s' => '%s'",name,id) end print(("-"):rep(40)) self.hue.subscribeTo(devices) self.hue.listSubscribedDevices() self.hue.listAllDevices() -- setTimeout(function() fibaro.call("3ab27084-d02f-44b9-bd56-70ea41163cb6","setColor","white") end, 0) -- setTimeout(function() fibaro.call("3ab27084-d02f-44b9-bd56-70ea41163cb6","turnOff") end, 0) -- setTimeout(function() fibaro.call("3ab27084-d02f-44b9-bd56-70ea41163cb6","turnOn") end, 3000) -- setTimeout(function() fibaro.call("3ab27084-d02f-44b9-bd56-70ea41163cb6","turnOff") end, 5000) -- setTimeout(function() fibaro.call("3ab27084-d02f-44b9-bd56-70ea41163cb6","turnOn") end, 7000) -- setTimeout(function() fibaro.call("3ab27084-d02f-44b9-bd56-70ea41163cb6","setDim",0,4000) end, 10000) -- setTimeout(function() fibaro.call("3ab27084-d02f-44b9-bd56-70ea41163cb6","setDim",100,4000) end, 15000) -- setTimeout(function() fibaro.call("Guest_room_Tim","setColor","green") end, 17000) -- setTimeout(function() print(fibaro.get("3ab27084-d02f-44b9-bd56-70ea41163cb6","on")) end, 19000) end function QuickApp:hueEvent(id,event) self:debug("Event:",uid," ",json.encode(event)) end function QuickApp:onInit() self:debug(self.name, self.id) self:setupUpHue() end This example uses 3 Hue devices, a motion/lux/temp sensor, a light (Tim), and a switch. The QA supports devices, rooms, zones and scenes. We can send command to the Hue light with fibaro.call. Note that the id is the Hue uid and not a device number. When a device changes state there is a callback to QuickApp:hueEvent with the uid and the event. There is a deviceMap (more about that later) accessible with self.hue.getRsrc("deviceMap") that maps Hue ids to the various properties of the device/resource. In particular, name and room. This allows us to build a map from our own IDs to hue ids as they may be easier to deal with. In the example above we map the light "3ab27084-d02f-44b9-bd56-70ea41163cb6" that has the name "Tim" and room "Guest room" to "Guest_room_Tim"="3ab27084-d02f-44b9-bd56-70ea41163cb6" in the self.hue.deviceMap[] table. That table is used by fibaro.call so if the id is in the self.hue.deviceMap table it will use that mapping. This allows us to call fibaro.call("Guest_room_Tim","setColor","green") in our example. but it also works with fibaro.call("3ab27084-d02f-44b9-bd56-70ea41163cb6","setColor","green") Only lights, rooms, zones and scenes can take commands: fibaro.call(uid,"turnOn"[,transition]) -- transition in ms. fibaro.call(uid,"turnOff"[,transition]) -- transition in ms. fibaro.call(uid,"toggle"[,transition]) -- transition in ms. fibaro.call(uid,"setDim",value[,transition])). -- value 0-100, transition in ms. fibaro.call(uid,"setTemperature",value[,transition]) -- value in mirek fibaro.call(uid,"setColor",<string> | {x=x, y=y} | {r=r,g=g,b=b}[,transition]) -- color string, ex "green" or x,y float values. (RGB support tbd) fibaro.call(uid,"recall"[,transition]) -- Recall scene for scene with uid. fibaro.call(uid,"sendRaw",<table>) -- POST raw command to Hue device with uid Sensor properties motion -- true/false temperature -- temperature light -- lux status -- connected/reachable power_state -- battery Buttons/switches properties button -- button pressed status -- connected/reachable power_state -- battery Lights properties on -- true/false dimming -- 0-100 color_temperature -- mirek color -- x,y status -- connected/reachable To use this there is a small Hue client library that needs to be included in the QA On top of this it would be relatively easy to create ex. childDevices for each device etc. So, there is some setup that needs be done for the HueConnector QA too. There are quickApp variables with "Hue_IP" and "Hue_User". The latter is the api key you get from the hub. You can dump the current devices, rooms, zones and scenes (the resources we can work with) When I log my resources looks like [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['1c10e485-e52b-4144-9991-46dbb2eedafa'] = { type='device', name='Middle window', model='LCT012', room='Living room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['21fc2e2f-05e6-4fbd-ad3b-a12762c88e72'] = { type='device', name='Hue white lamp 1', model='LWA001', room='Guest room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['2219eadd-9464-4149-b52d-073ed1d9754a'] = { type='device', name='Köksö2', model='LCG002', room='Köksö', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['2d7bfac8-688b-4889-b813-b927e875b533'] = { type='device', name='Star right', model='LCT012', room='Guest room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['3ab27084-d02f-44b9-bd56-70ea41163cb6'] = { type='device', name='Tim', model='LCT015', room='Guest room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['429ee799-9b86-43e5-bf31-ce3d06b45cc7'] = { type='device', name='Roof3', model='LCT012', room='Hall', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['598e4796-be01-482f-99c1-92f95fa8a18c'] = { type='device', name='Roof2', model='LCT012', room='Hall', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['59cbfb37-eba9-4746-9e64-ded409857abc'] = { type='device', name='Left window', model='LCT012', room='Living room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['5ddcb36b-f985-4876-88b6-a238c58b9dbf'] = { type='device', name='Star left', model='LCT012', room='Guest room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['721e69c5-bc75-4e99-b3ea-c05038ffa1af'] = { type='device', name='Star middle', model='LCT012', room='Guest room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['8a453c82-0072-4223-9c42-f395b5cb0c40'] = { type='device', name='Hue smart plug 1', model='LOM007', room='Guest room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['8dddf049-0a73-44e2-8fdd-e3c2310c1bb1'] = { type='device', name='Roof1', model='LCT012', room='Hall', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['9222ea53-37a6-4ac0-b57d-74bca1cfa23f'] = { type='device', name='Living room sensor', model='SML001', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['932bd43b-d8cd-44bc-b8bd-daaf72ae6f82'] = { type='device', name='Living room wall switch', model='RDM001', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['93d49902-6ce5-4383-9037-bfaeec8cd538'] = { type='device', name='Right window', model='LWO003', room='Living room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['9be444b2-1587-4fbe-89ac-efb809d7e629'] = { type='device', name='Roof lamp', model='LCT015', room='Bedroom', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['a001f510-48dd-47fc-b9ff-f779c40dd693'] = { type='device', name='Table1', model='LCA001', room='Living room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['a007e50b-0bdd-4e48-bee0-97636d57285a'] = { type='device', name='Dimmer switch', model='RWL021', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['a2b30b76-f044-46b6-9e1c-c8156baf00ab'] = { type='device', name='Table2', model='LCA001', room='Living room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['c4bef7c5-0173-4d57-ae6a-d7f8a14b4dde'] = { type='device', name='Roof5', model='LCT012', room='Hall', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['d3b04b72-c2f0-401f-85d7-a65f2db5c48e'] = { type='device', name='Roof4', model='LCT012', room='Hall', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['e82c2285-20f3-401f-9621-9dc356feb694'] = { type='device', name='Köksö1', model='LCG002', room='Köksö', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['f2a231b4-9c27-466f-8344-05c4012c742b'] = { type='device', name='Philips hue', model='BSB002', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['795959f5-9313-4aae-b930-b178b48249e0'] = { type='room', name='Guest room', model='bedroom', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['9ab242fb-fae1-47e5-a54f-51bb8e80ac31'] = { type='room', name='Köksö', model='kitchen', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['bbe472e6-8ea8-477b-a116-ca345452e056'] = { type='room', name='Hall', model='living_room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['bcd3daec-82a9-4de7-813a-3464beee0090'] = { type='room', name='Living room', model='living_room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['cc309f30-d0f4-4ab5-a31f-39cd2206be57'] = { type='room', name='Bedroom', model='bedroom', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['03541e04-3481-47e7-ad22-c167437ca905'] = { type='scene', name='Bright', model='unknown', room='Kitchen table', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['29d8ba67-980a-4ab9-9fa6-50a0f994b273'] = { type='scene', name='Bright', model='unknown', room='Window lights', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['dd2cef77-e4fb-455b-867f-bad85f8f846c'] = { type='scene', name='Miami', model='unknown', room='Guest room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['f1677f3f-db72-45b2-a922-97046cdbff9d'] = { type='scene', name='Bright', model='unknown', room='Guest room', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['39e1fc25-e926-42e5-a840-b2d21aaa08f3'] = { type='zone', name='Stars', model='recreation', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['79e44c37-15e0-4d93-8d89-230b14822270'] = { type='zone', name='Gymet', model='gym', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['9bfda4bf-b17e-4ec9-9123-a97afbcca814'] = { type='zone', name='Window lights', model='recreation', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['b5f12b5f-20c7-47a5-8535-c7a20fb9e66d'] = { type='zone', name='Kitchen island', model='kitchen', }, [12.08.2022] [10:02:42] [DEBUG] [QUICKAPP1001]: ['fe101c36-3dcc-4831-90f1-5052fc54e08b'] = { type='zone', name='Kitchen table', model='kitchen', }, That table is the one used when creating a custom mapping between names and Hue uids There will be improvements in the coming week and also hoping the V2 API will mature a bit more. There are some speed improvements that I know about that will improve the QA significantly...
- 43 replies
-
- 8
-
- qa
- development
-
(and 1 more)
Tagged with:
-
Hue white color lights issue with Fibaro
amatt posted a question in Other Devices / Third-party devices
I purchased some downlights that work with Hue. I added them to hue and ensured they work. then I added them to fibaro using the plugin with no issues. I set the color to what I want in the app (in this case I want bright white). I run a scene to figure out the value, brightness and saturation. I then put it in a VD as a saved color. once I press the saved color in fibaro the light changes to an off blue color instead of bright white. I can get the light back to a bright white by going to the hue app and adjusting the color so I know its not the light itself. Does anyone know if Hue changed a setting that does not allow the light to change to the correct color? in the app they have 2 different selections for colors and White not sure if this makes a difference on fibaro now. HC2 latest OS @T.Konopka -
Version 3.1
2,772 downloads
Philips HUE AIO VD v3.1 (standalone version) With Philips HUE preview VD v1.1 - brings easier setup and support for multiple Philips HUE bridges INTRODUCTION Philips HUE lighting brings colorful way of lighting experience. More about this lights you can find here https://www2.meethue.com/en-us Philips HUE AIO VD is All In One solution for HC2 owners to control Philips HUE lighting with support for all types of HUE lamps made by Philips and some other manufacturers. PREREQUISITES Fibaro Home Center 2 with firmware 4.120 or greater (tested up to 4.540) Philips HUE bridge V1 (round) with firmware up to 01041302 (released 05 February 2018) or Philips HUE bridge V2 (square) with firmware up to 1901181309 (released 07 February 2019) FEATURES Consists of two VD's: Philips HUE Preview VD which connects to Philips HUE bridge and downloads information of all lights and groups of lights and greatly simplifies installation of Philips HUE AIO VD that controls individual HUE bulbs or group of bulbs. Also added unreachable icon for Philips HUE bridge v1. Philips HUE Preview VD has button for generating authorization username and for easy connection to Philips HUE bridge Support for multiple HUE bridges and most of the Philips HUE bulbs including bulbs from other manufacturers that can be connected to HUE bridge. HUE AIO VD recognizes different types of bulbs like multicolor, white ambience and dimmable and enables proper controls Can control brightness, hue, saturation, color temperature and transition speed that can be set from instant to 10 seconds duration Buttons to activate colorloop efect and Alerts Multilanguage support with 27 languages included. VD's can use HC2 selected language or user can select any other available language. VD will be automatically translated to the selected language (visible after refreshing page on browser or refreshing network data on Fibaro mobile application) Easy setup for VD icons that will also setup icons for all buttons and sliders of the VD. (on UHASTM compatible version is even more easier to setup VD icons with Icon Preview VD) On HUE AIO VD user can setup separated on and off button or have on/off toggle button Self adding of global variables needed and global variable data integrity checking Automatic repair of global variables without user intervention New approach to programming other code to control this VD enables future upgrades without needing to change that code. (See more about that in User Manual provided) INSTALLATION Please check provided User Manual where all steps are explained in detail and this video made by @MarcoTorino71: PACKAGE CONTENT Philips HUE Preview VD v1.1 standalone Philips HUE AIO VD v3.1 standalone Icon pack Philips HUE E27 bulb indoor Icon pack Philips HUE E27 bulb outdoor Icon pack Philips HUE GU10 bulb indoor Icon pack Philips HUE GU10 bulb outdoor Icon pack Philips HUE LED strip indoor User Manual v1.1 EN CREDITS Many thanks to BodyArt, gucio1234 and many other Fibaro forum users for help with testing, translations and user manual. TERMS AND CONDITIONS Permission to use, copy, modify and distribute this software and its documentation for educational, research, personal use and non-profit purposes, without fee and without a signed licensing agreement is hereby granted, provided that the copyright notice, with "Terms and conditions" and "Disclaimer" appear in all copies, modifications and distributions. It is strictly forbidden to sell, rent, lease and/or lend this software for profit without prior consent from the Author. DISCLAIMER This software is provided by copyright owner "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the author and distributor be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. Fibar Group S.A. and their employees are not responsible for support of the Philips HUE AIO VD. Please contact the author Sankotronic, on the Fibaro Forum, for any questions or support required. LEGAL NOTICE HUE is registered trademark of Philips Lighting Holding B.V. registered internationally. LATEST NEWS 1 April 2019 Philips HUE bridge firmware new version 1901181309 is out. If you upgrade to this latest firmware Philips HUE AIO VD will continue function properly. VERSION HISTORY 3.1 - Corrected bug that was causing HUE AIO VD main loop to stop with error if user set light or group ID that does not exists on HUE bridge. Also corrected bug that was not updating list correctly after first scan if user removed or added light or group on HUE bridge. 3.0 - All In One solution, one VD for all types of bulbs and for control of individual light or group of lights with supporting Philips HUE Preview VD. 2.1 - added Philips HUE White dimmable VD of same version as color version. 2.1 - Corrected error handling when HUE bridge is not reachable. 2.0 - Added On/Off button; two version available: 2.0m with Main loop refresh or 2.0b with button refresh for systems with more than 15 HUE lamps to improve response and reduce network traffic; changing brightness, color or Saturation sliders now immediately refreshes VD status; code improved so users can easier setup necessary data 1.5 - Added sliders for color (hue) and Saturation, VD is now getting ID & TCP port setting from VD general tab 1.0 - Changing icons based on the brightness level, Changing icons based on HUE lights state (unreachable/error); Error handling for HUE response data, status information in the bottom bar of the VD; detailed comments in LUA code, main loop refresh code added Here is a new look of Philips HUE AIO VD and companion Philips HUE Preview VD: Enjoy coding and your new Philips HUE virtual device! Sankotronic PS This solution is only for HC2. If you have HCL then please check @AkilliYuva.com solution here: -
Best all, Im trying to change the color of my phillips hue ledstrip but i cant figure out how to do this via the rest api. The phillips leds are connected to the phillips bridge and i have the phillips hue plugin installed on my HC. does anyone know how i can do this?
-
Version 1.14
255 downloads
It's a "simple" QA that relies on the QuickAppChildren to realise the Hue devices. This means that the user interfaces are limited to what are supported by the child app classes. Supported Hue device classes: ZLLSwitch. Hue switch with 4 buttons. Creates centralSceneEvents similar to a Fibaro keyFob (com.fibaro.remoteController) The interpretation is keyId = hueKeyValue // 1000 keyAttribute = ({"Pressed","HeldDown","Released","Released"})[hueKeyValue % 1000 +1] It also supports setValue('value',value) to simulate a key press. ZLLTemperature. Hue temperature sensor. Behaves like a standard fibaro.com.temperatureSensor. ZLLLightLevel. Hue light sensor. Behaves like a standard fibaro.com.lightSensor. The device quickAppVariables 'daylight' and 'dark' is updated with resp. Hue attribute. ZLLPresence Hue presence sensor. Behaves like a standard fibaro.com.motionSensor. Extended color light Hue RGB light. Behaves like a fibaro.com.philipsHueLight. supports: fibaro.call(<id>,"turnOn") fibaro.call(<id>,"turnOff") fibaro.call(<id>,"toggle") fibaro.call(<id>,"setValue",value) -- dim value 0..100 If the value is a table the value is sent directly to the Hue light as a Hue property table. Ex. fibaro.call(<id>,"setValue",{effect='colorloop',bri=50}) fibaro.call(<id>,"setValue",{startup={customsettings={xy={0.73500005089041,0.26499994910959}}}}) fibaro.call(<id>,"setColor",red, green,blue). -- color 0..255 fibaro.call(<id>,"changeBrightness") -- brightness 0..255 fibaro.call(<id>,"changeHue") -- 0..65535 fibaro.call(<id>,"changeSaturation") -- 0..255 fibaro.call(<id>,"startLevelIncrease") fibaro.call(<id>,"startLevelDecrease") fibaro.call(<id>,"stopLevelChange") fibaro.call(<id>,"toggleDim",<boolean>) -- Toggle dim direction. true with 'stop' The device quickAppVariable 'state' is updated with the Hue state Dimmable light Hue dimmable white light. Behaves like a fibaro.com.multilevelSwitch. supports: fibaro.call(<id>,"turnOn") fibaro.call(<id>,"turnOff") fibaro.call(<id>,"toggle") fibaro.call(<id>,"setValue",value) --- dim value 0..100 If the value is a table the value is sent directly to the Hue light as a Hue property table. fibaro.call(<id>,"changeBrightness") -- brightness 0..255 fibaro.call(<id>,"startLevelIncrease") fibaro.call(<id>,"startLevelDecrease") fibaro.call(<id>,"stopLevelChange") fibaro.call(<id>,"toggleDim",<boolean>) -- Toggle dim direction. true with 'stop' The device quickAppVariable 'state' is updated with the Hue state Color temperature light Mapped as a Dimmable light Color light Hue color light. Behaves like a fibaro.com.colorController. supports: fibaro.call(<id>,"turnOn") fibaro.call(<id>,"turnOff") fibaro.call(<id>,"toggle") fibaro.call(<id>,"setValue",value) --- dim value 0..100 If the value is a table the value is sent directly to the Hue light as a Hue property table. fibaro.call(<id>,"setColor",red, green,blue). -- color 0..255 fibaro.call(<id>,"changeBrightness") -- brightness 0..255 fibaro.call(<id>,"startLevelIncrease") fibaro.call(<id>,"startLevelDecrease") fibaro.call(<id>,"stopLevelChange") The device quickAppVariable 'state' is updated with the Hue state fibaro.call(<id>,"toggleDim",<boolean>) -- Toggle dim direction. true with 'stop' Room Hue light group. Behaves like a fibaro.com.multilevelSwitch. fibaro.call(<id>,"turnOn") fibaro.call(<id>,"turnOff") fibaro.call(<id>,"toggle") fibaro.call(<id>,"setValue",value) --- dim value 0..100 If the value is a table the value is sent directly to the Hue group as a Hue property table. fibaro.call(<id>,"changeBrightness") -- brightness 0..255 fibaro.call(<id>,"startLevelIncrease") fibaro.call(<id>,"startLevelDecrease") fibaro.call(<id>,"stopLevelChange") fibaro.call(<id>,"setScene",<Hue scene ID or scene name>) fibaro.call(<id>,"toggleDim",<boolean>) -- Toggle dim direction. true with 'stop' Hue CLIPS devices CLIPPresence => com.fibaro.motionSensor class='ZLLPresence' CLIPTemperature. => com.fibaro.temperatureSensor class='ZLLTemperature' CLIPPressure => com.fibaro.binarySwitch class='BinarySwitch' CLIPHumidity => com.fibaro.humiditySensor. class='Humidity' CLIPOpenClose. => com.fibaro.binarySensor. class='BinarySensor' The startLevelIncrease, startLevelDecrease, and stopLevelChange makes it possible to bind a remote controller that support centralSceneEvent to dim when a button is held down and stop dimming when the button is released. The lights store their Hue values in a quickAppVariable 'state'. This can be retrieved like below and ex. used to set default startup values for Hue lights... local function getVar(id,name) local vars = api.get("/devices/"..id).properties.quickAppVariables or {} for _,v in ipairs(vars) do if v.name==name then return v.value end end end function QuickApp:main() state = getVar(1435,"state") -- retrieve current color fibaro.call(1435,{startup={customsettings={xy=state.xy}}) -- set as default startup end -
Hi, I've just got my HCL and installed the Hue plugin. I see all lights - and I am able to control them - on the main device page, though when I try to make a new scene (from blocks) the lights are not included in the device list? Please find images attached. Q: How do I get them to show up, within the scene builder?
-
Hi, I have several problems to get my HUE lights working white my Fibaro HC2. I have made a scene for my bathroom just to turn on and off the light in combination white a motion sensor. This is working fine but the light is always changing back to the warm color after about 24 hours. So i like to set the color by a LUA command. I used the debug function for the settings (see below) --[[ %% properties %% events %% globals --]] fibaro:debug(fibaro:getValue(162, "ui.brightness.value")) fibaro:debug(fibaro:getValue(162, "ui.saturation.value")) fibaro:debug(fibaro:getValue(162, "ui.hue.value")) If i change the Brightness on the HUE app the value changed. But the saturation and HUE value doesn't change at all. Whats the problem? is it a error of the Hue bridge (square one) or anything else??? This Youtube example looks oke to me: All you input is welcome and of course i can provite more information if necessary. Thank you in advance. Michel
-
Hi I am playing around with HUE together with my Fibaro system and so far it works fairly well. I am able to get my wall switch (with a dimmer 1 behind it) "control" the HUE indirectly via scenes. So I am able to switch the HUE on or off just by pressing S1 on the dimmer. However, if I use the HUE remote the dimmer won't know about it and comes out of sync. Working example: - press S1 on dimmer kicks of a LUA script that sends a "on" signal to the HUE light. - press S1 on dimme again sends an "off" signal to the HUE Not working example: - Hue started via the LUA script as mentioned above. If I then kill the light via the HUE remote the dimmer of course won't get a notification of that and still thinks it is "on". To "resync" the two devices I have to press S1 two times again. This of course works but, I would like to get another LUA script to pick up the status of the HUE and set the fibaro dimmer accordingly. I can see that the HUE light status (on/off) is picked up by my controller if I press the remote so my idea was to use the following code to pick it up and set the dimmer in the same state. --[[ %% properties 145 HUE light 164 Fibaro dimmer %% globals --]] local startSource = fibaro:getSourceTrigger(); if (fibaro:getValue(145, "ui.onOff.value") == '1') then fibaro:call(164, 'turnOn') else fibaro:call(164, 'turnOff') end But problem is that the script never executes. it is set to automatically start and I can execute it manually to verify it works but I still cannot get it to execute automatically (possible that it does not recognize the on/off trigger on the HUE). Any suggestion of how this could be done? And just to clarify, I am not using the dimmer to control the HUE lights directly. I am only using it to trigger the HUE via scripts. //Peter
-
Hi, I'm trying to create a QA/QD to get through APIs all my Philips Hue Data: Button 1: Get all Hue Groups Button 2: Get all Hue Scenes Button 3: Get all Hue Lights The purpose is to store this in a global variable and then be in a position to use this in other QD and scenes (saving light parameters for instance, to come back to initial state after an alert...or naming hue light in fibaro HC3 as they are in Philips hue environment...) I've managed to make it run, see code below, hope it could help some one... That's kind of a miracle considering my skills ^^ My issue starts where i actually do have 2 hue bridges (more than 50 lights). I would like to extract data from each of them and then merge result in a single table that I would then set as a global variable. This table should have one more key than the hue table: for the bridge source (1 or 2). I guess it's something with a for k,v in pairs(result) but i can't manage making it run To understand the code below: * to avoid having device id coded in scene and QA, they are all part of a Global Variable (mappingTable). If I want to change a device Id because replacing it, changing the Id in mappingTable updates all scenes and QA * i have coded only bridge 1. user information for bridge 2 are prepared * I've deleted all my attempts to present a running code if someone is interested Another question is around the function to get hue information in return. I'm not sure really understanding and mastering the synthax which remains a little bit obscur for me. could it be simpler? May I request some help and attention? Covid alert gives me sometime to search, but honestly, i'm stuck Thanks in advance for your support ^^ roomName = "SSLBUR" -- nom de la pièce cible floorName = "SSL" -- nom de l'étage de référence function QuickApp:globalVariable() self:debug("-- Chargement des variables globales nécessaires au QA") mappingTable=json.decode(tostring(fibaro.getGlobalVariable("mappingTable"))) end function QuickApp:hueConfigUpload() hueIP1 = mappingTable["SYSTEME"]["devices"]["hueBridge"]["hueBridge1"]["hueIP1"] huePort1 = mappingTable["SYSTEME"]["devices"]["hueBridge"]["hueBridge1"]["huePort1"] hueUser1 = mappingTable["SYSTEME"]["devices"]["hueBridge"]["hueBridge1"]["hueuser1"] hueIP2 = mappingTable["SYSTEME"]["devices"]["hueBridge"]["hueBridge2"]["hueIP2"] huePort2 = mappingTable["SYSTEME"]["devices"]["hueBridge"]["hueBridge2"]["huePort2"] hueUser2 = mappingTable["SYSTEME"]["devices"]["hueBridge"]["hueBridge2"]["hueuser2"] end function QuickApp:mappingHueGroup() self:globalVariable() self:hueConfigUpload() local address = "http://"..hueIP1.."/api/"..hueUser1.."/groups" self.http:request(address, { options = { headers = { Accept = "application/json"}, checkCertificate = true, method = 'GET' }, success = function(response) self:debug("response status:", response.status) self:debug("headers:", response.headers["Content-Type"]) fibaro.setGlobalVariable("mappingHueGroup", response.data) self:debug(response.data) local data = json.decode(response.data) self:debug(data["1"].name) end}) self:debug(mappingHueGroup) end function QuickApp:onInit() self:debug("") self:debug("-- Démarrage du code principal") self.http = net.HTTPClient({timeout=3000}) self:mappingHueGroup() -- self:mappingHueLight() -- self:mappingHueScene() end
-
I am not the Author, but this is such a great guide that I think it should be here. https://snillevilla.se/styr-philips-hue-lampor-med-fibaro-home-center-2/ You also need to check Developers.meethue.com and follow the tutorial there to get a user made for API https://developers.meethue.com/documentation/getting-started Files for icons and VD files here: https://github.com/snillevilla/Philips-Hue-VD-for-Fibaro-HC2
-
How do I put a GET status from Hue lamp into variable to store? HueGtw = Net.FHttp("IP-address",portNumber) HueGtw:GET('/api/xxxxxx/lights/3) Help would be appreciated?
-
HUE VD. Why triple click needed to activate??
baliya posted a question in Other Devices / Third-party devices
Hi everyone I'm dissapointed new user of fibaro HCL, my fault. Thought that the plugin for hue will let me use all hue components as they are, lights, sensors etc. Only way to use is with virtual devices, after digging a lot i've found a solution for my lamp, but when tested it only works doing 3 clicks in one seccond, so is useless. Some help will be greatly apreciated. Edited: Sorry may be this mut go on on¡thwer forum section -
Witam Posiadam Dimmer 2, podpięte są pod niego żarówki GU10 hue color, czy ktos sie orientuje czy one nie sa sciemnialne, poza aplikacja philips hue? dziala komus poprawnie hue + dimmer 2? pozdrawiam
-
Od pewnego czasu w aplikacji hue można ustawić zachowanie żarówek po włączeniu, fajnie by było gdyby udało się to zrobić za pomocą pluginu w HC, ustawiając w zależności od pory dnia barwę światła.
-
Hi possible interested users, I just inserted HUE bridge onto my system and becouse plugins are not suitable for automation, I looking for VD I find one - not VD but instruction to create VD: http://www.siio.com/lightshadow/philips-hue-virtual-module-in-fibaro-hc2-4742/ Actually this instruction need to some correction so I create VD and modified this a bit and saved as vfib some important modifications: * I created global variable to hold user key: Hue_User * I create global variable to hold starting number for icon set: Hue_IconStart * I changed port number to hardcoded: 80 * I changed VD port field to be used as light-id (lamp number) * Additionally I added label field on top of VD UI to get lamp name from bridge Result - You can add same VD several time - one for each lamp You need to control (I've started with 5 lamps in different rooms) For each lamp add one VD, configure IP address and lamp id (into port number) One more decision point: initially I had plan to put bridge IP into global variable. I had to change this idea and leave IP as config parameter for VD. The reason is that on my second house I probably need several bridges with different IP Unfortunateli responding to siio.com page fails (they have some error on page preventing responses) NB! attached file is not mine origin - this is created using instructions (ideas) from SIIO and only corrected. required icon set You find from referenced siio.com page HUE-Bulb-HS.vfib
-
This is my first topic in a series of post I'm going to write about the advanced LUA scenes I wrote for my home automation project. My goal is not flipping a light scene with a phone but for 90% autonome home automation. Besides posting LUA code I give you more insight why I came to this routine. It may help you with designing your own automation routines. Disclaimer: I am not a professional programmer and I post the scenes as is. I have no time to make the LUA scenes generic like other great members do on this forum. I just post my LUA code to share knowlegde and inspire you to create awesome things! Advanced home wake-up routine with Philips Hue and HC2 Applies to: Fibaro Home Center 2 and Philips HUE bridge. GOALS Use my Philips Hue led strips as a wake-up light. Use 1 app to schedule the whole home wake-up routine. Start the morning routine when walking downstairs (check motion). Turn on the lights only when it’s dark (read lux). In our bedroom we integrated a Philips Hue lightstrip in the ceiling and use this with the Philips Hue app as a wake-up light. It beautifully fakes a sunrise in our whole room. As we use the Hue app to set our wake-up alarm I use this app to trigger the Home Center to run a wake-up routine for the rest of the house. TL;DR Set recurring wake-up schedule in the Philips Hue app. Home Center LUA scene 1 reads schedules at 04:00 with the keyword Wake in it. If schedule is set for today and motion is detected at the hallway after the scheduled time (scene 2), run wake-up routine. HOW I IMPLEMENTED IT IN WORDS Reading Hue schedules from the bridge cannot be done with the Fibaro Hue plug-in. Therefore I wrote a LUA scene to read the Hue schedules from the Hue bridge and run the wake-up routine at the schedules wake-up time. I achieved this with 2 LUA scenes: Scene 1 runs every minute and polls the Hue bridge schedules at 04:00. If a wake-up is scheduled for today write the wake-up times to a global variable. Every minute it checks if there is a wake-up planned by reading the same global variable and if so it sets the WakeUpReady global variable to 1. Scene 2 runs when motion detected by a Fibaro Motion Sensor. If it detects motion it checks if the global variable WakeUpReady is set to 1 and runs the wake-up routine. SCENE 1 EXPLAINED You can download the full LUA scenes at the bottom of this post. I only describe snippets of my code to make you understand what it does and show the challenges I ran into. TAG YOUR HUE SCHEDULE WITH A WAKE-UP STRING IN IT! To know which schedules are used for wake-up I set all those schedules with the Wake keyword in it. Like Wake-up weekday’s and Wake-up weekends. In the LUA scene I find these schedules with the code: if name:find('Wake') and status == 'enabled' then ... end RECURRING DAY’S ARE SAVED AS A BITMASK IN THE HUE BRIDGE The Hue API states: The Hue bridge saves the recurring day’s as a bitmask. You have to convert this bitmask to weekday’s. So you can check if the alarm is set for today. The first step is to convert decimal to a binary. I did this with the folowing LUA function: function bin(dec) local result = "" repeat local divres = dec / 2 local int, frac = math.modf(divres) dec = int result = math.ceil(frac) .. result until dec == 0 local StrNumber StrNumber = string.format(result, "s") local nbZero nbZero = 8 - string.len(StrNumber) local Sresult Sresult = string.rep("0", nbZero)..StrNumber return Sresult end Then I have a binary representation of the scheduled weekday’s. For example: mo tu we th fr sa su 1 1 1 1 0 1 0 You see the alarm is set for monday, tuesday, wednesday, thursday and saturday. With this I can determine if the alarm is set for today: if name:find('Wake') and status == 'enabled' then local huedays, huetime = string.match(timepattern, 'W(.*)/T(.*)') -- Hue starts at monday, LUA starts at sunday, so I have to fix this. local dayofweek = os.date("*t").wday-1 if dayofweek == 0 then dayofweek = 7 end local scheduleddays = bin(huedays) -- dayofweek+1 because a week is 7 days and binary is 8 digits, so -- a have a pre 0 local waketoday = string.sub(scheduleddays, dayofweek+1, dayofweek+1) if waketoday == '1' then wakeUpAlarms = wakeUpAlarms .. huetime:sub(1, -4) .. '|' end ... end WRITE WAKE-UP TIME TO GLOBAL VARIABLE If there is an alarm schedule for today write it to a global variable for later use: if wakeUpAlarms ~= '' then fibaro:setGlobal("WakeUpTime", wakeUpAlarms:sub(1, -2)) -- remove last | else -- If no schedules are set, write disabled to the global variable. fibaro:setGlobal("WakeUpTime", "disabled") end SET WAKEUPREADY GLOBAL VARIABLE FOR MOTION SENSOR LUA SCENE The LUA scene runs every minute using the code: setTimeout(tempFunc, 60*1000) At 04:00 it checks the schedules in the Hue bridge, but every minute it checks the WakeUpTime global variable to set the wakeupReady global variable to 1. This variable triggers the second LUA scene used by the motion sensor. local wakeupTime = fibaro:getGlobal("WakeUpTime") if wakeupTime ~= "disabled" then local waketimes = {} for match in (wakeupTime..'|'):gmatch("(.-)"..'|') do table.insert(waketimes, match); end for k, v in pairs(waketimes) do if os.date("%H:%M") == v then fibaro:setGlobal("WakeUpReady", 1) fibaro:debug("It's wake-up time! Set motion detector ready!") end end end SCENE 2 EXPLAINED (MOTION SENSOR PART) With scene 1 I created a global variable setting to determine if the wake-up routine must run. Now I create a second scene to act if there is motion in our hallway. CHECK FOR MOTION AND IF ALARM IS NOT ARMED First I want to check if there is motion and if the alarm is not armed with the line: if tonumber(fibaro:getValue(158, "value")) > 0 and tonumber(fibaro:getValue(158, "armed")) == 0 then ... RUN WAKE-UP ROUTINE ONLY IF IT’S DARK OUTSIDE The Philips Hue wake-up schedule runs always because our bedroom had curtains and the room is always dark. Downstairs I only want to run the wake-up routine when it’s dark outside. The wakeupReady global variable check’s if the routine needs to run when there is motion (set with scene 1). The line below gets the current lux reading from the Fibaro motion sensor: fibaro:getValue(160, "value") If the illuminance is below 20 I want to turn on my lights. if wakeupReady == "1" then fibaro:setGlobal("WakeUpReady", 0) -- Disable trigger for current wake-up time. -- check lux local currentLux = tonumber(fibaro:getValue(160, "value")) -- id 160 is sensors light device. -- If it's dark then start wake-up routine if currentLux < 20 then fibaro:debug("Illuminance measuring " .. currentLux .. " lx, starting wake-up routine.") fibaro:call(44, "setValue", "8") -- Spots keuken (8%) fibaro:call(29, "setValue", "5") -- Tafel eethoek (5%) fibaro:call(106 , "turnOn") -- Bolles (aan) fibaro:call(118 , "turnOn") -- Spot voordeur (aan) fibaro:call(156, "sendPush", "Started wake-up routine. Debug: " .. currentLux .. " lx") else fibaro:debug("Illuminance measuring " .. currentLux .. " lx, do nothing.") end ... DOWNLOAD MY SCENES COMPLETE LUA CODE You can download the full LUA scene code from GitHub: Scene 1: Wakeup.lua Scene 2: MotionRoutine1.lua You have to change the device id’s from my motion sensors in this scene to your own id’s! And don't forget to set the scenes to run automatic in the Fibaro Home Center 2
-
Hello! I am trying to make a scene in LUA where I can dim my Hue bulbs. I have a Sunricher 4ch switch, which I have created scenes for turnOn and turnOff Hue bulbs, and it works nicely, as in the picture below: I want to make a new scene, where the button´s HELD DOWN function should utilize dimming of the Hue bulb. I have tested some commands from the Hue Developer API, and found out that if I "PUT" the below command to the Hue-bulb, it increases the saturation with 1 for each time I press "PUT". Is it possible to make a repeat loop / while loop or similar that sends this command? I know this is not the LUA API, it is in the REST API. I can not quite see how to send similar commands in LUA, unless there is a way to make a repeat loop that takes the saturation value and adds "1" e.g. each 10 millisecond while the switch is in HELD DOWN state?
- 1 reply
-
- hue
- philips hue
-
(and 1 more)
Tagged with:
-
HCL Wirtualne Urządzenie - czy istnieje możliwość debbugowania
rcom posted a question in Home Center Lite
Witam, Męczę się z wirtualnym urządzeniem pod HCL. Tworzę wirtualne urządzenie które ma sterować żarówką HUE wg opisu z forum, niestety urządzenie nie działa. Moje pytanie dotyczy kwestii debbugowania. Czy istnieje możliwość sprawdzenia co robi utworzony przycisk w wirtualnym urządzeniu, jaki PUT wysyła do mostka HUE. Dodam że jak steruję z samego mostka IP/debug/clip.html to wszystko działa prawidłowo, żaróka zapala się i gaśnie. Przykład jednego z przycsków, który chciałbym zdebbugować : PUT /api/mój_klucz_użytkownika_API_HUE/lights/1/state HTTP/1.10x0D0x0AHost:192.168.1.2190x0D0x0AContent-Length: 450x0D0x0A0x0D0x0A{"on":true, "sat":255, "bri":255,"hue":12000}0x0D0x0A Pozdrawiam Raf Centralka - niestety HC LITE wersja firmware : 4.521 BETA -
For the Philips Hue lovers there is cheap Osram Lightify Smart Plug, which can be easily added to Philips Hue bridge in order to make non Hue lamps controlled by Hue bridge. I made a simple small VD based on @Sankotronic's Hue devices. ----------------------------------------------------------------------------- -- Osram Smart Plug On/Off ----------------------------------------------------------------------------- --[[ ----------------------------------------------------------------------------- Version 1.0 Original VD written by CHRISSXCROSS © 2015 VD modified and upgraded by Sankotronic © 2016 ----------------------------------------------------------------------------- --]] local _f = fibaro local hueID = 40; -- get name of the user from global value local hueUser = _f:getGlobal('HueUser'); local iconOff = 1226; local iconOn = 1227; local iconUnreachable = 1012; local iconError = 1013; -- END OF CODE PART FOR USERS TO EDIT AND SETUP -------------------------- Id = _f:getSelfId() Ip = _f:get(Id, "IPAddress") Port = _f:get(Id, "TCPPort") -- connect to the Hue bridge Hue = Net.FHttp(Ip, Port) -- Now do light, get previous settings and send new -- HTTP GET to get all the info from the light(s) resp ,stat , err = Hue:GET('/api/'..hueUser..'/lights/'..hueID); -- continue if HTTP status code is 200 if (tonumber(stat) == 200) then jT = json.decode(resp) -- get the on state hueOn = jT.state.on _f:debug("hueOn = " .. tostring(hueOn)); hueReachable = jT.state.reachable _f:debug("hueReachable = " .. tostring(hueReachable)); -- if light is reachable then check if it is ON or OFF to toggle it if (hueReachable == true) then if (hueOn == false) then hueOn = true; ic = iconOn; else hueOn = false; ic = iconOff; end -- HTTP PUT to set the new values resp, stat, err = Hue:PUT('/api/'..hueUser..'/lights/'..hueID..'/state', '{"on":'..tostring(hueOn)..'}'); _f:call(Id, "setProperty", "currentIcon", ic); else _f:log("Hue: Unit not reachable"); -- change the icon to unreachable _f:call(Id, "setProperty", "currentIcon", iconUnreachable); end else _f:log("Hue: Bridge not reachable"); _f:call(Id, "setProperty", "currentIcon", iconError); end I hope someone will have use for it
-
-