{"id":13579322,"url":"https://github.com/Pythm/ad-Lightwand","last_synced_at":"2025-04-05T20:33:46.625Z","repository":{"id":206792203,"uuid":"717712705","full_name":"Pythm/ad-Lightwand","owner":"Pythm","description":"Extensive control of lights based on time of day with mode event in addition to motion, presence, lux, rain, and media player sensors","archived":false,"fork":false,"pushed_at":"2025-03-12T22:46:36.000Z","size":508,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-12T23:28:41.008Z","etag":null,"topics":["appdaemon","appdaemon-apps","automated-lights","home-assistant","hue-lights","lightcontrol","lights","lux-sensor","motion-sensor","mqtt","python","toggle-leds","zigbee2mqtt"],"latest_commit_sha":null,"homepage":"https://github.com/Pythm/ad-Lightwand","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pythm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"Pythm","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://www.buymeacoffee.com/pythm"]}},"created_at":"2023-11-12T10:54:18.000Z","updated_at":"2025-03-12T22:46:39.000Z","dependencies_parsed_at":"2024-01-12T23:55:24.493Z","dependency_job_id":"24d446a7-1e0d-48b7-9e76-3fe7e60912cf","html_url":"https://github.com/Pythm/ad-Lightwand","commit_stats":null,"previous_names":["pythm/lightwand","pythm/ad-lightwand"],"tags_count":33,"template":false,"template_full_name":"ludeeus/ad-hacs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pythm%2Fad-Lightwand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pythm%2Fad-Lightwand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pythm%2Fad-Lightwand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pythm%2Fad-Lightwand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pythm","download_url":"https://codeload.github.com/Pythm/ad-Lightwand/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399874,"owners_count":20932876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appdaemon","appdaemon-apps","automated-lights","home-assistant","hue-lights","lightcontrol","lights","lux-sensor","motion-sensor","mqtt","python","toggle-leds","zigbee2mqtt"],"created_at":"2024-08-01T15:01:38.374Z","updated_at":"2025-04-05T20:33:41.616Z","avatar_url":"https://github.com/Pythm.png","language":"Python","funding_links":["https://patreon.com/Pythm","https://www.buymeacoffee.com/pythm"],"categories":["Python"],"sub_categories":[],"readme":"# Lightwand by Pythm\nan Appdaemon app for extensive control of lights via [Home Assistant](https://www.home-assistant.io/) or MQTT. Set light data based on time of day or use Mode Change event in Home Assistant to set your light, in addition to lux, rain and multiple motion, presence, and media player sensors.\n\n![Picture is generated with AI](/_d4d6a73c-b264-4fa6-b431-6d403c01c1f5.jpg)\n\n## Installation\n1. Download the `Lightwand` directory from inside the `apps` directory here to your [Appdaemon](https://appdaemon.readthedocs.io/en/latest/) `apps` directory.\n2. Add the configuration to a .yaml or .toml file to enable the `Lightwand` module. Minimum required in your configuration is:\n\n```yaml\nnameyourRoom:\n  module: lightwand\n  class: Room\n  Lights:\n    - lights:\n      - light.yourLight\n```\n\n## App usage and configuration\n\u003e [!TIP]\n\u003e All sections and configurations except the minimum above are optional, so you use only what is applicable.\n\u003e Each app contains one `Room` with all of the sensors you want to use for that room and define all the lights to automate.\n\n\n## Lights\nAll lights for the room is configured as either `MQTTLights` to control lights directly via MQTT or `Lights` as Home Assistant lights/switches. Optionally as Home Assistant switches you can configure `ToggleLights` if you have lights/bulbs that dim with toggle.\nEach of the different light types can have multiple \u003cb\u003e-lights\u003c/b\u003e as lists with the lights / switches. Each set containing the same settings including automations, motions, modes, lux on/off/constraints and conditions.\n\n#### MQTTLights\nDeveloped for [zigbee2mqtt](https://www.zigbee2mqtt.io/). There you can control everything from switches to dimmers and RGB lights to Philips Hue. Just define light_data with the brightness, color, effect you want to control. Check your zigbee2mqtt for what your light supports. Brightness is set in range 1-255.\n\u003cbr\u003e\n\u003cbr\u003eCan be used with [zwaveJsUi](https://github.com/zwave-js/zwave-js-ui?tab=readme-ov-file#readme). Only tested with switches and dimmable light. Brigtness is set with 'value' in range 1 to 99.\n\u003cbr\u003e\n\u003cbr\u003eMqtt light names are full topics for targets excluding /set, case sensitive.\n\u003cbr\u003eZigbee2mqtt should be something like: zigbee2mqtt/YourLightName\n\u003cbr\u003eZwave could be something like: zwave/YourLightName/switch_multilevel/endpoint_1/targetValue\n\u003cbr\u003eApp will set up subscription to MQTT topics.\n\n\u003e [!TIP]\n\u003e I recommend [MQTT Explorer](https://mqtt-explorer.com/) or similar to find Zwave topic.\n\n\n#### Home Assistant Lights\nIs configured with Lights and can control switches and lights. Use entity-id including type as name. Check your entity in Home Assistant for what your light supports as data like brightness, transition, rgb, etc.\n\n#### ToggleLights\nToggleLights is Home Assistant switch entities. Toggles are configured with a `toggle` number on how many times to turn on light to get wanted dim instead of light_data for dimmable lights. Input `num_dim_steps` as number of dim steps in bulb.\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Mode change events\n\u003e [!IMPORTANT]\n\u003e This app listens to event \"MODE_CHANGE\" in Home Assistant to set different light modes with 'normal' mode as default setting.\n\u003e The use of events in Appdaemon and Home Assistant is well documented in [Appdaemon docs - Events](https://appdaemon.readthedocs.io/en/latest/APPGUIDE.html#events)\n\nTo set mode from another appdaemon app simply use:\n```python\nself.fire_event(\"MODE_CHANGE\", mode = 'your_mode_name')\n```\n\nOr define scripts in Home Assistant and activate with automation or in lovelace:\n\n```yaml\nday:\n  alias: \"your_mode_name\"\n  sequence:\n    - event: MODE_CHANGE\n      event_data:\n        mode: 'your_mode_name'\n```\n\n\u003e [!TIP]\n\u003e Check out [ModeManagement](https://github.com/Pythm/ad-ModeManagement) example code if you want to automate some default away/morning/night modes.\n\n### Mode names\n\u003e [!IMPORTANT]\n\u003e When an event with \"MODE_CHANGE\" is triggered, it will check thru all defined modes for all lights in the app/Room.\n\u003e \u003cbr\u003e- If mode is defined in room and for light it will update light with state/data defined in mode.\n\u003e \u003cbr\u003e- If mode is not defined in light but is present in room, light will be set to normal mode.\n\u003e \u003cbr\u003e- If mode is not defined in room, the lights will keep existing mode.\n\n##### Predefined mode names \n\nAll mode names except \u003cb\u003e'custom'\u003c/b\u003e can be defined in 'light_modes' with your own configuration.\n\n\u003e [!NOTE]\n\u003e Setting mode to 'custom' stops all automation like mediaplayer, motion or lux control.\n\nThe predefined mode names with default turn on/off:\n\n\u003cbr\u003eMode names that defaults to off:\n\u003cbr\u003e- `away`\n\u003cbr\u003e- `off`\n\u003cbr\u003e- `night`\n\u003cbr\u003eMode names with default full brightness:\n\u003cbr\u003e- `fire`\n\u003cbr\u003e- `wash`\n\u003cbr\u003e\n\nOther modes with additional behaviour:\n\u003cbr\u003e- 'morning' behaves as 'normal' mode with conditions and Lux constraints. Useful for some extra light in morning during workdays.\n\u003cbr\u003eWhen 'morning' mode is triggered, mode will be set to 'normal' if not defined in room and after media players is turned off.\n\u003cbr\u003e- 'night*' and 'off'\n\u003cbr\u003eIn addition to 'night' mode you can configure modes beginning with 'night', for instance 'night_Kids_Bedroom'.\n\u003cbr\u003eAll modes starting with 'night' in addition to 'off' will disable motion detection.\n\u003cbr\u003eSet room in off mode with 'off_' + app name.\n\u003cbr\u003e\n\u003cbr\u003e'custom' mode will disable all automation and keep light as is for all lights. Useful for special days you want to do something different with the lights.\n\n\u003e [!TIP]\n\u003e You are free to define whatever you like even for the names with default value. Useful for rgb lighting to set a colourtemp for wash or keep some lights lux constrained during night.\n\n\n## Automating lights\nSetting up automation is configured by time with a state and/or light data.\n\n\n### Defining times\nAutomations contains a set of times for each set of light and is activated with mode 'normal'. If you only want lux control on/off, you do not need to set up any time automations.\n\u003e [!NOTE]\n\u003e Both Lux constraint and your conditions need to be meet before lights turns on in normal automation.\n\nAutomations are based on time, which can be either solar-based (using sunrise/sunset times) or clock-based. Optionally, in addition to `time`, you can also specify `orLater` to combine solar and clock-based times for more accurate control over when lights change depending on the season. If `orLater` is defined, it will shift all subsequent times by the same timedelta as long as not fixed or changed from sunrise to sunset time. In the example under with clock-based time at 08:00:00 and a solar-based time at sunrise + 00:15:00 defined with `orLater`, the clock-based time at 20:00 will shift by the same amount as the time difference between 08:00 and sunrise + 15 minutes. However, if you use a sunset time instead, the timeshift will stop at the first sunset time. A new timeshift is introduced every time `orLater` is used.\n\nApp deletes automations that have a time that are earlier than previous automation time if a time with solar-based and clock-based time is mixed in automations and the `orLater` is not used.\n\nYou can in prevent shifts and deletions with a `fixed`: True, which locks the time from being moved or deleted. I use this to make sure the lights in children's rooms turn off at bedtime, even when the sun sets after.\n\n```yaml\n      automations:\n      - time: '08:00:00'\n        orLater: 'sunrise + 00:15:00'\n      - time: '20:00:00'\n        fixed: True\n        state: turn_off\n```\n\n\u003e [!TIP]\n\u003e There are ready logs inn the python file commented out with # to easily log changes to times done by the app. Search code for: `Check if your times are acting as planned. Uncomment line below to get logging on time change`. Just uncomment the log line to see what changes the app does to your timing.\n\n### Chosing between state and light_data\nEach defined time can have a **state** and/or a **light_data**.\n\n\u003cb\u003eState\u003c/b\u003e defines behavior.\n- turn_off: Turns off light at the given time. Can also be defined in motion lights to turn off and keep the light off after the given time until the next time. E.g., turn off at kids' bedroom at 21:00.\n- adjust: Does not turn on or off the light but adjusts `light_data` at the given time. Turn on/off with other modes or manual switch. Not applicable for motion.\n\n\u003cb\u003eLight data\u003c/b\u003e contains a set of attributes to be set to the light, such as brightness, transition, color temperature, RGB color, effect, etc. Light data must have either brightness (HA or Zigbee2Mqtt) or value (zwaveJsUi). Other attributes are optional.\n\nUse `dimrate` to set brightness transition -/+ 1 brightness per x minutes. Dimming from previous timed brightness until brightness is met.\n\n\u003e [!NOTE]\n\u003e If '00:00:00' is not defined a turn_off state will be default at midnight if other times is configured in automations or motionlights for lights.\n\nIf you only provide time in automation, the state will be set to `none` and the light will turn on if conditions are met. However, if you do not provide any light data it will not adjust anything.\nIf you do not provide time you must specify state.\n\n\n### Motion behaviour\nConfigure `motionlights` to change light based on motion sensors in room. A minimum configuration to have the light turn on if lux constraints and conditions are met is:\n\n```yaml\n  motion_sensors:\n    - motion_sensor: binary_sensor.yourMotionSensor\n  Lights:\n    - lights:\n      - light.kitchen\n      motionlights:\n        state: turn_on\n```\n\nYou can provide `offset` to dimmable lights to increase compared to `light_data` in automation for normal light. Insted of `state` you can define `light_data`, or even input your `automations` here with times if you want different brightness during the day for motion lights.\n\nAutomations example:\n```yaml\n      motionlights:\n      - time: '00:00:00'\n        light_data:\n          brightness: 3\n      - time: '06:50:00'\n        light_data:\n          brightness: 160\n      - time: '08:30:00'\n        orLater: 'sunrise + 00:15:00'\n        light_data:\n          brightness: 180\n      - time: 'sunrise + 01:30:00'\n        light_data:\n          brightness: 120\n      - time: '20:00:00'\n        orLater: 'sunset + 00:30:00'\n        dimrate: 2\n        light_data:\n          brightness: 3\n```\n\u003e [!NOTE]\n\u003e When motion is active the light will not dim down. Motion detected will also not turn down brightness to set motion, in case other modes sets brightness higher e.g. \u003cb\u003ewash\u003c/b\u003e active and set to 255 and motion only set to 125, light will stay at 255 brightness.\n\u003e \u003cbr\u003eIf media players is on or night* / off mode is active motion lighting is deactivated.\n\n\n\nState with offset example:\n```yaml\n      motionlights:\n        state: turn_on\n        offset: 35\n```\n\n\n### Configure mode light\nYou can create as many modes in \u003cb\u003elight_mode\u003c/b\u003e as you are able to have the time to configure, and they can be defined with automations for different light settings during the day, light_data for one fits all setting or with a simple state: turn_on, lux_controlled, turn_off or manual.\n\n`automations` is configured and functions the same as automations for normal with lux and conditions constraints.\n`light_data` can be used if you only want one setting to turn on light with given data. This is Lux constrained but Conditions do not need to be met.\n`state` defines behaviour as in normal automation and can be turn_on, lux_controlled, turn_off or manual.\n  - `turn_on` turns on light regardless of Lux and Conditions\n  - `lux_controlled` only turns/keeps light on if lux is below lux_constraint\n  - `turn_off` Turns off light\n  - `manual` Completly manual on/off/brightness etc.\n\n`offset` can be provided to state lux_controlled or turn_on to increase or (-) decrease brightness based on light_data in normal automation.\n\nAn example :\n\n```yaml\n      light_modes:\n        - mode: morning\n          light_data: # Define specific light attributes for given mode\n            brightness: 220\n            transition: 3\n            color_temp: 427\n        - mode: decor\n          state: turn_on # Turns on regardless of Lux constraints or defined conditions\n          offset: -20 # Optional offset from brightness defined in normal mode\n        - mode: tv\n          state: turn_off\n        - mode: away\n          state: lux_controlled # Follows Lux Turn on/off\n        - mode: nightKid\n          state: manual # Disable all automation when this mode is active\n        - mode: night\n          automations: # Define own automation for mode. Lux constraints and defined conditions must be meet.\n          - time: '00:00:00'\n          - time: '03:00:00'\n            state: turn_off\n          - time: '23:00:00'\n```\n\n## Sensors\nMQTT sensor names are full topics for targets excluding /set, case sensitive. App will subscribe to MQTT topics. Home Assistant sensors uses entity-id as sensor name.\n\n### Motion Sensors and Presence trackers\nYou can define time after sensor no longer detects motion before it turns light back with `delay` in seconds, and define constraints to each sensor as an if statement that must be true for motion to activate. Inherits Appdaemon API to self.\n\nTrackers will trigger 'presence' mode when new == home and sets 'away' mode if all trackers defined in room is not home. When presence is detected it will go to 'normal' mode if old state is 'away' and 'presence' is not defined in light_mode. Trackers will not change mode unless it is normal or away.\n\n```yaml\n  motion_sensors:\n    - motion_sensor: binary_sensor.yourMotionSensor\n  MQTT_motion_sensors:\n    - motion_sensor: zigbee2mqtt/KITCHEN_sensor\n      delay: 300\n      motion_constraints: \"self.now_is_between('06:50:00', '23:00:00') and self.get_tracker_state('person.wife') == 'home' or self.get_state('switch.kitch_espresso') == 'on' \"\n  presence:\n    - tracker: person.wife\n      tracker_constraints: \"self.now_is_between('06:30:00', '23:00:00') \"\n```\n\n\u003e [!TIP]\n\u003e Tracker will set mode as away when not home but there is no restrictions on calling new modes or normal when away.\n\nWith `bed_sensor` light mode will stay at nigth mode until bed is exited, to then turn on normal operations when bed is exited.\n\n### Media Players\nSorted by priority if more than one media player is defined in a room. Can be any sensor or switch with an on/off state. Define the name of the mode for each sensor and define light attributes in `light_modes`. The \"media mode\" will set the light and keep it as the media mode when motion is detected, as well as during morning, normal, and night* modes. Calling any other modes will set the light to the new mode. If any of the morning, normal, or night* modes are called when the media is on, the media mode will be active again.\n\n\u003e [!TIP]\n\u003e Input `delay` option when a TV reports a 'on' state shortly after being turned off and then reported a 'off' state again to avoid lights dimming up and down and up again.\n\n```yaml\n  mediaplayers:\n    - mediaplayer: binary_sensor.yourXboxGamerTag\n      mode: pc\n    - mediaplayer: media_player.tv\n      mode: tv\n      delay: 0\n```\n\n### Weather sensors\nYou can configure two outdoor lux sensors with the second ending with '_2' and it will keep the highest lux or last if other is not updated last 15 minutes. There can only be one room lux sensor but it can be either MQTT or Home Assistant sensor. Rain sensor can for now only be Home Assistant sensor.\n\n```yaml\n  OutLux_sensor: sensor.lux_sensor\n  OutLuxMQTT_2: zigbee2mqtt/OutdoorHueLux\n  RoomLux_sensor: sensor.lux_sensor\n  RoomLuxMQTT: zwave/KITCHEN_sensor/sensor_multilevel/endpoint_0/Illuminance\n  rain_sensor: sensor.netatmo_rain\n```\n\n### Custom options\nCreate a list of `options` with choises to make for each room.\n\u003e [!TIP]\n\u003e  Enable motion detection during `night` mode with `night_motion`\n\n\u003e [!TIP]\n\u003e `exclude_from_custom` will exclude the room from 'custom' mode and 'wash' mode. Can be useful for rooms you forget to adjust light, like outdoor lights and kid's bedroom.\n\n### Conditions and constraints\nYou can use Lux sensors to control or constrain lights. Optionally you can provide IF statements to be meet for light to turn on at normal/morning/motion mode or with automations defined. Inherits Appdaemon Api as ADapi.\n\u003cbr\u003eI use this on some of the lights in my livingroom and kitchen for when my wife is not home but without using the presence sensor because I do not want to set my rooms as away.\nYou can define any statement you want so I have not figured out a better way than to create a 'listen_sensors' list for the sensors you use in statement so light can be updated when the condition changes.\n\n```yaml\n  listen_sensors:\n    - person.wife\n  #Some light data...\n      conditions:\n        - \"self.ADapi.get_tracker_state('person.wife') == 'home'\"\n      lux_constraint: 12000\n      lux_turn_on: 10000\n      lux_turn_off: 12000\n      room_lux_constraint: 100\n      room_lux_turn_on: 80\n      room_lux_turn_off: 100\n```\n\n## Manual changes to lights\nIf you manage to configure every light to your liking, normal automation should be sufficient for day-to-day use without intervention. However, there are days when you'll need something else. To avoid creating a mode for every possible scenario, I've tried to keep the automations so that if you set or adjust lights manually, they will stay until:\n-Motion inclusive given delay has ended\n-Lux levels go from below to above lux constraint. They will remain on if turned on when lux is above.\n-Mode is changed\n-Time automation is executed when conditions are met (e.g., if lux is above the constraint, automation will not execute)\n\n\n### Persistent storage\nDefine a path to store json files with 'json_path' for persistent storage. This will store current mode for room and outdoor lux, room lux, and if lights is on for lights that has adjust/manual states and MQTT lights. Toggle lights will store current toggles.\n\n## Namespace\nIf you have defined a namespace for MQTT other than default you need to define your namespace with `MQTT_namespace`. Same for HASS you need to define your namespace with `HASS_namespace`.\n\n# Get started\nEasisest to start off with is to copy this example and update with your sensors and lights and build from that. There is a lot of list/dictionaries that needs to be correctly indented. And remember: All sections and configurations are optional, so you use only what is applicable.\n\n## App configuration\n\n```yaml\nyour_room_name:\n  module: lightwand\n  class: Room\n  # Configure path to store Json for mode and lux data. This will give you some persistency when restarted. Adds 'your_room_name' + '.json' to the json_path\n  json_path: /path/to/your/storage/\n\n  # Namespaces for MQTT and HASS if other than default.\n  MQTT_namespace: mqtt\n  HASS_namespace: hass\n\n  # Lux sensors for lux control and constraint\n  OutLux_sensor: sensor.lux_sensor\n  OutLuxMQTT_2: zigbee2mqtt/OutdoorHueLux\n  RoomLux_sensor: sensor.lux_sensor\n  RoomLuxMQTT: zwave/KITCHEN_sensor/sensor_multilevel/endpoint_0/Illuminance\n\n  # HA sensor for detection of rain. If rain is detected, it will raise lux constraint by * 1.5\n  rain_sensor: sensor.netatmo_rain\n\n  # Listen to sensors to update Lights when there is a change\n  listen_sensors:\n    - person.wife\n\n  # Exclude the room from custom mode or allow motion detection during night\n  options:\n    - exclude_from_custom\n    - night_motion\n\n  # Motion sensors.\n  # Input delay in seconds before light turns back from motion to 'mode' light\n  # motion_constraints takes an if statement that must be true for motion to activate. Inherits Appdaemon API to self\n    # Example from my kitchen:\n    # \"self.now_is_between('06:50:00', '23:00:00') and self.get_tracker_state('person.yourwife') == 'home' or self.get_state('switch.espresso') == 'on' \"\n  motion_sensors:\n    - motion_sensor: binary_sensor.motion_sensor_home_security_motion_detection\n      delay: 600\n      motion_constraints: \"self.now_is_between('06:30:00', '21:00:00')\"\n  MQTT_motion_sensors:\n    - motion_sensor: zigbee2mqtt/\n      delay: 600\n      motion_constraints: \"self.now_is_between('06:30:00', '21:00:00')\"\n\n  # Presence detection. Configuration is same as motion sensors\n  # Sets mode as away for room if all trackers are not equal to 'home'.\n  # Sets mode to presence if defined in light_modes or normal if not defined when returning home\n  presence:\n    - tracker: person.yourwife\n      delay: 600\n      tracker_constraints: \"self.now_is_between('06:30:00', '22:00:00') \"\n    - tracker: person.yourself\n      delay: 600\n      tracker_constraints: \"self.now_is_between('06:30:00', '22:00:00') \"\n\n  # Media players. Sorted by priority if more than one mediaplayer is defined in room. Can be any sensor or switch with on/off state\n  # Define name of mode here and define light attributes in 'light_modes'\n  mediaplayers:\n    - mediaplayer: binary_sensor.yourXboxGamerTag\n      mode: pc\n    - mediaplayer: media_player.tv\n      mode: tv\n\n  # Configure lights and switches as Lights. Lights that dim with toggle is configured with 'ToggleLights' insted of 'Lights'\n  MQTTLights:\n    # Configure as many light with different settings you wish in a room and each lights configuration can have many lights/switches\n    - lights:\n      - zigbee2mqtt/hue1\n      - zigbee2mqtt/hue2\n\n      # Configure default light behaviour for 'normal' mode with automations. Not needed if you only want lux control on/off\n      # Both Lux and Conditions need to be meet before lights turns on\n      # 'time' can be both time with sunrise/sunset +- and fixed time\n      # 'state' defines behavior:\n      #     adjust: Does not turn on or off light but adjusts light_data on given time. Turn on/off with other modes or manual switch\n      #     turn_off: Turns off light at given time\n      #     No need to define 'state' in 'time' for the times you want light to turn on\n      # 'light_data' can contain a set of attributes to be set to light: brightness, transition, color_temp, rgb_color, effect, etc\n      automations:\n      - time: '06:30:00'\n        light_data:\n          brightness: 255\n          effect: sunrise\n      - time: '09:15:00'\n        orLater: 'sunrise + 00:20:00'\n        light_data:\n          brightness: 255\n          effect: colorloop\n      - time: 'sunrise + 01:30:00'\n        light_data:\n          brightness: 120\n          transition: 3\n          color:\n            x: 0.5075\n            y: 0.4102\n      - time: '22:00:00'\n        light_data:\n          brightness: 80\n          effect: fireplace\n      - time: '22:01:00'\n        dimrate: 2 # Will start to dim from previous brightness (80) - 1 per x minutes. In this case every 2 minutes.\n        light_data:\n          brightness: 10\n          effect: fireplace\n      - time: '23:00:00'\n        state: turn_off\n\n      # Configure motion lights same way as normal automations\n      motionlights:\n      - time: '06:30:00'\n        light_data:\n          brightness: 160\n      - time: '08:30:00'\n        orLater: 'sunrise + 00:30:00'\n        light_data:\n          brightness: 120\n      - time: 'sunset - 00:30:00'\n        orLater: '19:00:00'\n        light_data:\n          brightness: 140\n      - time: 'sunset + 00:30:00'\n        light_data:\n          brightness: 110\n      - time: '23:00:00'\n        state: turn_off # Turn off at given time even when motion.\n        fixed: True\n\n      # Define light modes to change light accordingly.\n      # Modes can be configured with automations, light_data or state: turn_on, lux_controlled or turn_off\n      # 'automations' is configured and functions the same as automations for normal with lux and conditions constraints\n      # Most common use for automation in mode is 'normal' mode turn_off and 'motion' containing automation\n      # 'light_data' can be used if you only want one setting to turn on light with given data\n      #      Lux constrained but Conditions do not need to be met\n      # 'state' defines behaviour:\n      #     'turn_on' turns on light regardless of Lux and Conditions\n      #     'lux_controlled' only keeps light on if lux is below lux_constraint\n      #     'turn_off' Turns off light\n      # 'offset' can be provided if state 'lux_controlled' or 'turn_on' is defined to increase or decrease brightness\n      #      based on 'light_data' in normal automation\n      light_modes:\n        - mode: night_kid\n          light_data:\n            brightness: 10\n        - mode: presence\n          state: turn_on\n        - mode: motion\n          automations:\n          - time: '00:00:00'\n            light_data:\n              brightness: 100\n          - time: '04:00:00'\n            light_data:\n              brightness: 110\n          - time: sunrise - 00:10:00\n            light_data:\n              brightness: 160\n          - time: sunset + 00:30:00\n            light_data:\n              brightness: 60\n        - mode: pc\n          state: turn_off\n        - mode: tv\n          state: lux_controlled\n          offset: -50\n\n  ToggleLights:\n    - lights:\n      - switch.toggle_bulb\n      toggle: 2 # On toggles to get desired dim\n      num_dim_steps: 3 # Number of dim steps in bulb\n      toggle_speed: 0.8 # Set time in seconds between each toggle\n      light_modes:\n        - mode: night\n          toggle: 3\n        - mode: gaming\n          state: turn_off\n\n      # Lux constraints will only check when a new update to light is sent, like motion/presence, media player on/off or normal mode\n      # Lux turn on will send a new update to light if new lux detected is below set target\n      # Lux turn off will send a new update to light if new lux detected is above set target\n      lux_constraint: 12000\n      lux_turn_on: 10000\n      lux_turn_off: 12000\n      room_lux_constraint: 100\n      room_lux_turn_on: 80\n      room_lux_turn_off: 100\n\n      # Conditions as if statement to be meet for light to turn on at normal/morning/motion mode or with automations defined\n      # Inherits Appdaemon Api as ADapi.\n      conditions:\n        - \"self.ADapi.get_tracker_state('person.kid') == 'home'\"\n        - \"self.ADapi.now_is_between('06:50:00', '23:30:00')\"\n```\n\n### Key definitions for defining app\nkey | optional | type | default | introduced in | description\n-- | -- | -- | -- | -- | --\n`module` | False | string | | v1.0.0 | The module name of the app.\n`class` | False | string | | v1.0.0 | The name of the Class.\n`HASS_namespace` | True | string | default | v1.1.0 | HASS namespace\n`MQTT_namespace` | True | string | default | v1.1.0 | MQTT namespace\n`options` | True | list | False | v1.1.5 | Can contain exclude_from_custom to exclude the room from custom mode, and night_motion to allow motion detection during night\n`json_path` | True | string | | v1.0.0 | Use Json for persistency when restarted. Adds 'your_room_name' + '.json' to the json_path\n`rain_sensor` | True | sensor | | v1.0.0 | HA sensor for detection of rain. If rain is detected, it will raise lux constraint by * 1.5\n`OutLux_sensor` | True | sensor | | v1.0.0 | Sensor for Lux detection\n`OutLuxMQTT` | True | MQTT sensor | | v1.0.0 | Lux detection via MQTT\n`OutLux_sensor_2` | True | sensor | | v1.0.3 | Secondary Sensor for Lux detection\n`OutLuxMQTT_2` | True | MQTT sensor | | v1.0.3 | Secondary Lux detection via MQTT\n`RoomLuxMQTT` | True | string | | v1.0.0 | MQTT lux sensor for lux control and constraint\n`RoomLux_sensor` | True | string | | v1.0.0 | HA Lux sensor for lux control and constraint\n`mediaplayers` | True | dict | | v1.0.0 | Media players sorted by priority if more than one mediaplayer is defined\n`motion_sensors` | True | dict | | v1.0.0 | HA Motion sensors\n`MQTT_motion_sensors` | True | dict | | v1.0.0 | MQTT motion sensors\n`presence` | True | dict | | v1.0.0 | HA Presence detection\n`Lights` | True | list | | v1.0.0 | HA lights\n`MQTTLights` | True | list | | v1.1.0 | MQTT lights\n`ToggleLights` | True | list | | v1.0.0 | Use ToggleLights instead of Lights for bulbs/lights that dim with toggle\n`listen_sensors` | True | list | | v1.1.0 | List of sensors to listen to state change for updating light\n\n### Key definitions to add to motion and presence sensors\nkey | optional | type | default | introduced in | description\n-- | -- | -- | -- | -- | --\n`motion_sensor` | True | sensor | | v1.0.0 | Motion sensor\n`delay` | True | int | 60 | v1.0.0 | Input delay in seconds before light turns back from motion to current mode\n`motion_constraints` | True | string | | v1.0.0 | if statement that must be true for motion to activate. Inherits Appdaemon API to self\n`bed_sensor` | True | sensor | | v1.1.6 | This will wait until bed is exited to turn on light in room when night ended\n\n### Key definitions to add to Lights\nkey | optional | type | default | introduced in | description\n-- | -- | -- | -- | -- | --\n`lights` | True | list | | v1.0.0 | list of lights\n`automations` | True | dict | | v1.0.0 | Configure default light behaviour for 'normal' mode with automations\n`motionlights` | True | dict | | v1.0.0 | Configure default light behaviour for motion detected\n`light_modes` | True | dict | | v1.0.0 | Name of mode. Define light modes to change light accordingly\n`lux_constraint` | True | int | | v1.0.0 | Outdoor lux constraint\n`lux_turn_on` | True | int | | v1.0.0 | Outdoor lux to turn on light if below\n`lux_turn_off` | True | int | | v1.0.0 | Outdoor lux to turn off light if above\n`room_lux_constraint` | True | int | | v1.0.0 | Room lux constraint\n`room_lux_turn_on` | True | int | | v1.0.0 | Room lux to turn on light if below\n`room_lux_turn_off` | True | int | | v1.0.0 | Room lux to turn off light if above\n`conditions` | True | list | | v1.0.0 | Conditions as if statement. Inherits Appdaemon Api as ADapi\n`toggle_speed` | True | float | 1 | v1.1.4 | Set time in seconds between each toggle. Supports sub second with 0.x\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPythm%2Fad-Lightwand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPythm%2Fad-Lightwand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPythm%2Fad-Lightwand/lists"}