Giter Club home page Giter Club logo

hue-to-loxone's Introduction

logo

HitCount Pylint Code Smells Maintainability Rating Security Rating Bugs Vulnerabilities Duplicated Lines (%) Reliability Rating Technical Debt

Philips Hue to Loxone Bridge

This python script allows you to integrate your Philips Hue smart lighting system with your Loxone system. By running this script, events in the Hue system are forwarded to the Loxone Miniserver in the form of UDP packets. The signal-flow is like this:

graph LR
    A[Hue Accessory] --> B[Hue Bridge]
    B --> C[✨Philips Hue to Loxone Bridge✨]
    C --> D[Loxone Miniserver]

Note

This Python script only sends events from the Hue bridge to the Loxone Miniserver. If you want to control your Hue lights from the Miniserver, have a look at this PicoC script that can run on the Miniserver.


Supported Event Types

The bridge is designed to parse the following events. (If you are missing an event type, hit me up and we'll see if i can add it 😎)

Event Type Description
BUTTON This event is triggered when a button on a Hue Dimmer Switch, Hue Button or an other similar device is pressed. The button_state is 1 as long the as the button is pressed and 0 when released.

Note that for BUTTON events, the {item_state} has a format of {button_number}/{button_state}. This is because a single hue accessory can have multiple buttons.

Example: hue_event/sensors/29/1/1
MOTION This event is triggered when motion is detected by a Hue motion sensor. The state is 1 when motion is detected and 0 when no motion is detected.

Example: hue_event/sensors/34/1
LIGHT_LEVEL This event is triggered when the light level measured by a Hue motion sensor changes. The state represents the current light level in Lux.

Example: hue_event/sensors/35/230 = 230 Lux
TEMPERATURE This event is triggered when the temperature changes on a Hue motion sensor. The state represents the current temperature as a float value.

Example: hue_event/sensors/36/25.36 = 25.36°C
LIGHT This event is triggered when the state of a light changes. The state is 1 when the light is on and 0 when the light is off.

Example: hue_event/lights/4/1
GROUPED_LIGHT This event is triggered when the state of a light group changes. The state is 1 when the group is on and 0 when the group is off.

Example: hue_event/groups/3/0
DEVICE_POWER This event is triggered when the battery level of a Hue device changes. The state represents the current battery level.

Each event is sent to the Loxone Miniserver as a UDP packet in the format hue_event/{item_type}/{item_id}/{item_state}. Every Hue item has a unique id. If an item can have multiple different event types, then a unique id for every event type is generated.

To make it easier for you to assign the id to a specific item, the python script prints all names and id's during startup.

Getting Started

This guide assumes that you have git and python 3 installed on you system. If true, continue with these steps:

  1. Clone this repository.

    git clone https://github.com/marcelschreiner/hue-to-loxone.git
  2. Install the required dependencies (python libraries) with pip. pip3 is traditionally used on Raspberry Pis to install libraries for Python 3 other systems may use pip.

    pip3 install requests
    pip3 install aiohue
  3. Generate a Philips Hue API key, to access you Hue bridge. To do this configure the IP of you Hue bridge in get_api_key.py. Then execute the script, it will guide you through the process.

    python3 get_api_key.py
  4. Modify the configuration variables in the hue2lox.py script as described in the Configuration section.

  5. Run the Philips Hue to Loxone bridge using the following command:

    python3 hue2lox.py
  6. OPTIONAL: (Example for Raspberry Pi) If you want the python script to automatically start if your system starts, open rc.local

    sudo nano /etc/rc.local

    Then add the path to the hue2lox.py script:

    ...
    python3 /home/pi/hue2lox.py &
    exit 0
    

Configuration

Open the script and modify the following variables to match your setup:

  • HUE_IP: Set this to the IP address of your Philips Hue bridge.
  • HUE_API_KEY: Set this to your Hue bridge's API key.
  • LOXONE_IP: Set this to the IP address of your Loxone Miniserver.
  • LOXONE_UDP_PORT: Set this to the UDP port your Loxone Miniserver is configured to listening on.

Configuring a Virtual UDP Input in Loxone Config

To integrate the Philips Hue events with your Loxone Miniserver, you need to configure a virtual UDP input in the Loxone Config. Follow the steps below:

  1. Open the Loxone Config and connect to your Miniserver.

  2. Navigate to the Periphery tree in the structure view.

  3. Right-click on the Virtual Inputs and select Add Virtual UDP Input.

  4. In the properties of the newly created Virtual UDP Input, set the UDP Command to for exaple hue_event/sensors/42/\v.

License

Released under the MIT License, this code is yours to command! 🚀 Modify it, tweak it, use it to your heart's content. Let's create something amazing together! 💻🌟

hue-to-loxone's People

Contributors

marcelschreiner avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

pforrmi

hue-to-loxone's Issues

Question about udp packets to loxone server

Hi,

First of all thank you for posting this script. I've got it working today and I see all events being listed on my linux machine.
The script is sending the UDP packets to Loxone however in Loxone I'm not receiving all the information of the event.

For example : on my linux machine I see this event output

received event update LightLevel(id='61954f6b-e89f-4741-85ce-f0c30aee2788', owner=ResourceIdentifier(rid='cb58b3b2-cfcd-4e14-ab17-a8cff89325d3', rtype=<ResourceTypes.DEVICE: 'device'>), enabled=True, light=LightLevelFeature(light_level_report=LightLevelReport(changed=datetime.datetime(2023, 10, 29, 14, 31, 8, 296000, tzinfo=datetime.timezone.utc), light_level=4825), light_level=4825, light_level_valid=True), id_v1='/sensors/40', type=<ResourceTypes.LIGHT_LEVEL: 'light_level'>)
EVENT: {event}

However in Loxone I'm only getting ;

15;15:32:37.043;Loxone Miniserver;Received;10.10.4.41;Philips Hue;5000;hue_event{sensor_id}/{sensor_state};68 75 65 5f 65 76 65 6e 74 7b 73 65 6e 73 6f 72 5f 69 64 7d 2f 7b 73 65 6e 73 6f 72 5f 73 74 61 74 65 7d;;

But the objects field remains empty ...

Do you have any idea what could be the problem ?

Receive Hue bridge group events

Hi,

I see that the aiohue library also contains all necessary syntax regarding Hue light groups and I've been looking how this could be integrated in your code but my knowledge is not enought to find a solution.

What I'm looking for is to get a event when a group is turned on or (True or false in Hue). Then I can use this value in a virtual input and update the status of the on/off switch in Loxone whenever a light group is turning on or off.

As I'm using Hue automation with light sensors, groups are being turned off automatically after x minutes. For the moment I receive the event when motion is triggered and so the group is turned on, but when the timer expires it's the Hue bridge that switches the light group off so that event is not being reported leaving the button in Loxone in the ON state while the group is no longer in the ON state.

Is this something you could add to the script ?

Kind regards,

Filip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.