Git Product home page Git Product logo

crownstone-home-assistant's Introduction

hacs_badge GitHub release (latest by date) Maintained

Crownstone Home Assistant Integration Beta

Crownstone Home Assistant banner

Features

Crownstone Home Assistant integration beta to test new features before they are integrated into the core version.

The Crownstone integration is available in Home Assistant core since version 2021.10.0. It is however limited in features and only supports switching and dimming Crownstones for now. With time, features will be migrated from this version to the core version.

This version supports the following extra features over the core integration:

  • Instant data (names and firmware version) updates
  • Dynamically adding and removing devices/entities when Crownstones or locations are added or removed in the app
  • Real-time power usage measurements using the Crownstone USB
  • Real-time energy usage statistics using the Crownstone USB, which can be added to the energy dashboard
  • Presence devices/entities to keep track of who is in which room
  • Custom presence triggers that can be used in automations to make your whole home react to presence changes
  • Custom presence conditions that can be used in automations to check current presence of specific users in a room

This version builds directly on top of the core integration, so the core is stable. The extra features have been tested well, but have not been reviewed by any Home Assistant members, it is therefore possible they are not fully optimized yet or contain bugs. For the most stable experience, we recommend using the core version. If you like the extra features, you can keep using the HACS version.

Crownstone integration dashboard example

Installation

HACS

Visit the HACS installation page to install HACS, and the HACS setup page to enabled HACS in Home Assistant.

In HACS, Click the 3 dots button in the top right corner, and click custom repositories. Select category integration, and add the link of this repository.

After adding the repository, in the HACS store, click the "+ explore & add repositories" button in the bottom right corner, and search for Crownstone. Then just follow the installation steps. Make sure to select the newest version!

Manually

Copy all files from custom_components/crownstone/ to custom_components/crownstone inside your HA config folder.

Languages

This beta version of the integration currently supports English and Dutch.

Crownstone USB dongle

To use the Crownstone USB dongle in Home Assistant, plug the dongle in a USB port of the device that runs Home Assistant. In most cases that will be a Raspberry Pi. You must then add the dongle to a Sphere in the Crownstone app, otherwise it will not work. It can be added like any other Crownstone. In the app, simply press the "+" button, select Crownstone, and then select Crownstone USB.

When setting up the Crownstone integration in Home Assistant, you will have to select the serial port of the Crownstone USB dongle. You can do so by selecting the correct entry from the list:

Crownstone USB setup

Future USB dongles will likely have the Crownstone dongle product string. However older dongles will show CP2104 USB to UART Bridge Controller for the description. If you have more dongles with VID 10C4 and PID EA60, for example, the Z-wave Zooz stick, unplug those devices and only leave the Crownstone dongle connected, and select the Refresh list option to scan again, to make sure you select the correct dongle.

If your USB dongle is not listed because you created your own udev rule and the system fails to detect it, you can select the Enter manually option, and manually enter the path. E.g. /dev/crownstone. If your entered port is incorrect and the integration cannot establish a connection, it will show a notification and use the cloud instead. You can always try the setup again later from the integration options.

If you don't want to set up a USB dongle, select Don't use USB. The Crownstone Cloud will be used to switch Crownstones, and power/energy entities will not be added.

In case you have multiple Spheres configured in the Crownstone app, you will have to select the Sphere where the USB dongle is configured, because the dongle by itself is not aware in which Sphere it is. You can check this by going into the Crownstone app. If you only have 1 Sphere, this step will be skipped.

Crownstone USB Sphere

If you did not set up a USB dongle from the beginning or the setup was unsuccessful, you can start the setup again at any point from the integration options. Go to configuration -> integrations, look for your Crownstone account and click Configure.

Crownstone options disabled

When checking this option and clicking submit, you can instantly start configuring a Crownstone USB dongle. When a dongle was set up, this option will be checked. Unchecking this option will remove the existing USB configuration and use the Crownstone Cloud again.

You can also change the Sphere where the USB is configured on the fly. This depends on where it is configured in the Crownstone app. It is quite rare that this changes, but in case you have a mobile instance you could add the USB to an other Sphere in the Crownstone app, and change this setting.

Crownstone options enabled

Comparison

The integration works with the Crownstone Cloud and the Crownstone USB dongle. The differences between the two are only relevant for the Crownstones. The integration uses the Crownstone Cloud by default, to use the Crownstone USB you'll have to purchase one from the Crownstone store.

Presence updates and data updates are always done using the Crownstone Cloud.

Crownstone Cloud

  • Switching Crownstones
  • Dimming Crownstones
  • State updates in Home Assistant when switching from Crownstone app
  • Can switch multiple Crownstones at once
  • No delay when switching Crownstones
  • State updates in Home Assistant when using lightswitch with Switchcraft
  • Can switch Crownstones independently (no smartphone in proximity required)
  • Can use power usage & energy usage entities

Crownstone USB Dongle

  • Switching Crownstones
  • Dimming Crownstones
  • State updates in Home Assistant when switching from Crownstone app
  • Can switch multiple Crownstones at once
  • No delay when switching Crownstones
  • State updates in Home Assistant when using lightswitch with Switchcraft
  • Can switch Crownstones independently (no smartphone in proximity required)
  • Can use power usage & energy usage entities

Get your Crownstone USB dongle here and enhance your Home Assistant experience!

Remote access

In case you have multiple Spheres, only the Crownstones that are located in the same Sphere as the USB dongle can use the dongle, as it uses BLE and hooks directly into the Crownstone mesh network. The Crownstones from the other Spheres will use the Cloud. If you want to switch Crownstones in your other Spheres remotely, you will need a device at the receiving end to switch the Crownstones for you, as the Cloud only posts a command for the switch. This device is usually a smarthphone, or a Crownstone hub (gateway).

In case you want to control your Home Assistant instance remotely and switch Crownstones, make sure you are using a Crownstone USB so it can switch Crownstones even when you're not home. It is recommended to use Home Assistant Cloud (Nabu Casa) to easily set up a remote connection with your Home Assistant instance.

Crownstones

Crownstone are represented in the light platform, and can switch or dim. You can create a card in the overview and add your Crownstone entities to have a nice overview of your Crownstones! If a Crownstone supports dimming, there will be a brightness slider to dim your Crownstone.

Crownstone entity

When the ability state of dimming is changed through the Crownstone app, your config entry will reload to process the change in supported features.

Presence

The unique selling point of Crownstone, the presence on room level, is also available in Home Assistant!

The state sensor is a string of the first names of the people who are in the room. It is possible for multiple people to be in the same room, the names of the users is separated by a comma.

Apart from the room presence there is also sphere presence. this shows who is currently in the sphere (house, apartment). If a user is at home (in the sphere), the user's name will be shown in sphere presence and one of the room presence entities.

The Crownstone app is leading the presence functionality, for any issues with your presence detection make sure to go to your Crownstone app and retrain your rooms. 4 Crownstones are required for the localisation on room level. If you don't have 4 Crownstones, it will only show your presence in the sphere (house).

Presence device automation

To create automations with the Crownstone presence detection on room level, device triggers and conditions are available. You can trigger automations on presence changes for a specific user or any user, and optionally check if someone is present in a room before switching devices.

The following device triggers are available for the Crownstone presence devices:

  • A user has left a room / the house
  • A user has entered a room / the house
  • Any user has entered a room / the house
  • Any user has left a room / the house

The following device conditions are available for the Crownstone presence devices:

  • Any user is present in a room / the house
  • Users are present in a room / the house
  • Users are not present in a room / the house

Setting up an automation using the UI

  • go to configuration -> automations -> add automation -> start with an empty automation -> select a presence device and trigger in the trigger section or a presence device and condition in the condition section.
  • go to configuration -> devices -> select device -> new automation -> select a trigger or condition.

The names of the users are their full name, So first name + last name. You can see what name you have configured by entering the Crownstone app, and going to Settings -> My Account.

Power usage & Energy usage

Crownstone's live power usage streaming, and energy usage summation, are is also available in Home Assistant. Because of the constant updates, this functionality is only available when using the Crownstone USB dongle.

The power usage and energy usage for each Crownstone update every minute, or instantly for a particular Crownstone when switching it.

Energy usage

  • Takes the total energy amount directly from the Crownstone. This can be a big value depending on when the Crownstone started counting.
  • A Crownstone's energy usage total amount is reset back to 0 when the Crownstone is rebooted (power loss, reset or after a software update). This means the value of the energy sensor will also go back to 0, this does not affect the total amount saved in Home Assistant. You can view your delta's in the Home Assistant energy dashboard.

Crownstone power usage

The connection entity depends on whether this entity is in the same Sphere as the Crownstone USB. You should have selected in which Sphere it is in the configuration. If a device is not in the same Sphere as the Crownstone USB and can therefore not be switched by it or receive energy/power updates, the connection entity will show "Cloud".

Roadmap

  • Publish initial Crownstone integration to Home Assistant Core
  • Optimize configuration flow for easier setup
  • Create device triggers for Presence devices
  • Add power usage entities to Crownstone devices
  • Fix state updates coming from the Crownstone app not being done in Home Assistant
  • Dynamically update data & add/remove Crownstone and Location devices without restarting or reloading
  • Add energy usage entities to Crownstone devices
  • Create device conditions for Presence devices

Any ideas for future updates? Let us know!

Crownstones with HA Pi

License

Open-source license

This software is provided under a noncontagious open-source license towards the open-source community. It's available under three open-source licenses:

  • License: LGPL v3+, Apache, MIT

License: LGPL v3 License: MIT License: Apache 2.0

Commercial license

This software can also be provided under a commercial license. If you are not an open-source developer or are not planning to release adaptations to the code under one or multiple of the mentioned licenses, contact us to obtain a commercial license.

  • License: Crownstone commercial license

Contact

For any question contact us at https://crownstone.rocks/contact/ or on our discord server through https://crownstone.rocks/forum/.

crownstone-home-assistant's People

Contributors

ricarch97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crownstone-home-assistant's Issues

Energy value stops incrementing

I experience problems with energy monitoring for some months now. It has worked correctly in the beginning. The problem started with one Crownstone that still reports power usage as expected, but does not increment the energy count. Recently more devices don't seem to update correctly anymore. It started with a high power user (the heat pump). It first worked correctly (or at least it seemed logical values), then it didn't increment the energy value on 'low' energy usage (+/- below 100W), now it does not increment any more. Also at the heat cycle for warm water (which typically uses between 800W and 1,2kW for 2 hours) doesn't show any energy increment.

image
Power usage heat pump

image
Energy usage heat pump

Now also the freezer and refrigerator seem of. For example, the freezer did use today (according to the crownstone) only 0.13kWh, while its power usage is +/- 34W. I would have expected an energy value larger 0.4kWh.

image
Power usage freezer

image
Energy usage freezer

The freezer crownstone only seems to report the larger energy spikes and not the background spikes anymore.

I don't know if this is related to #8. I expect it is different. Initially I expected it to be a problem with the crownstone firmware (counters that are to small or so), but now more devices have the same issue it might be something different. Are the energy counters switching to a lower resolution if it obtains larger values? I'm running the crownstones for a while so it could be that I reached some limit?

Energy is 0kWh using dongle

I'm using the Crownstone beta version on Home Assistant Docker with the USB Dongle. Switching works, but energy readings don't.

Installing seems fine, when logging in and selecting the USB Dongle, I see my Crownstones in the Overview.
Each item has:
Connection: USB Dongle
Power: 0 W
Energy: 0 kWh
Light: <switch on/off>
Crownstone HA

Switching the light works.
Clicking on either Power or Energy shows a graph with only 0 as a value.
In the Crownstone App I see energy readings; the USB Dongle is in the same sphere (and green in the app).
I'd try to set a different USB Dongle device (/dev/USBttyx), but then I get an error message in the logbook. So a bad USB Dongle setup is unlikely to be the cause.

The Logbook mentions for each Connection:

  • Connection became unavailable
  • Connection changed to Cloud
  • Connection became unavailable
  • Connection changed to USB Dongle
  • Connection became unavailable

The Docker is run in privileged and unprivileged mode, but the outcome is the same.
Homeassistant version used is 2022.8.2. Crownstone Plugin version is 2.0.6.

I would like to see the energy readings. How to proceed?

Home Assistant instable because of this integration

I tested this integration thoroughly, but it turned out that my Home Assistant instance got very instable because of it. The system became slow and sometimes unresponsive. After I removed the crownstone integration my HA insurance became stable again.

Not sure what the exact reason in this code is, but after installing this integration the problem was gone.

[Feature Request] show energy & power usage

Would it be difficult to add support for energy usage and power usage? It is a nice feature and would make nice dashboards in HA. I wouldn't need a real time 'high performance' energy usage. Updates of the energy usage in 15 mins or 1 hour could be sufficient (1 minute intervals would be better). Power usage could be less frequent snapshots also.

BTW I'm using the USB stick

USB dongle not found

I have HA running in a docker container (nothing special, just FROM homeassistant/home-assistant). The dongle is passed in as /dev/crownstone by docker compose, but not found by the crownstone HACS plugin.
No ports are found at all by list_ports.comports() in crownstone_uart/core/uart/UartManager.py. I've fixed it for now by changing self.uart_instance.initialize_usb() to self.uart_instance.initialize_usb('/dev/crownstone') in custom_components/crownstone/helpers.py, but that's of course not a long term solution.
If you need more info to debug this, let me know!

Support for energy management

The latest release of home-assistant adds new possibilities for energy management. (https://www.home-assistant.io/blog/2021/08/04/home-energy-management/). The crownstones could be used as device monitors. To do that, energy consumption should be reported in kWh. They also should meet the requirements for long-term statistics (https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics). I believe all information is available but needs some small adaption to meet the requirements but would make the crownstones great additions for the energy management (both measuring and switching, ... )

Automation based on presence can't be created

I'm running HA 2021.12.9 and want to create an automation based on the presence in a specific room. When I want to add this automation, I don't get the possibility to create such and automation. When starting an automation from scratch, I can't select any trigger.

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.