Skip to content

Commit

Permalink
Merge pull request #86 from christophheich/main
Browse files Browse the repository at this point in the history
Fixed target temperature not being set and cover position throwing an exception
  • Loading branch information
grimmpp authored Mar 24, 2024
2 parents b704bbe + eea07c7 commit 2fbbfa3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ eltako:
4. **Update Home Assistant configuration** ``/config/configuration.yaml`` and add all devices and sensors you want to integrate. See [How to update Home Assistant Configuration](https://github.com/grimmpp/home-assistant-eltako/tree/main/docs/update_home_assistant_configuration.md) to see how the configuration should look like.
There is also a scipt which can detect devices and sensors and creates a prepared configuration because in big setups it can be a little effort doing that manually. For more details have a look into [Device and Sensor Discovery for Home Assistant Configuration](https://github.com/grimmpp/home-assistant-eltako/tree/main/eltakodevice_discovery/)

> [!IMPORTANT]
> Devices that are later removed from the configuration are not deleted in HA. Although it is possible to delete the entity, it is currently not possible to delete the device via a button. The easiest and quickest way to clean up is to delete the Eltako HUB and create a new one. Don't worry, the automations, scenes, scripts, dashboard settings and historical data will not be lost. These are linked to the device ID and are reassigned after the Eltako HUB has been created.
>
> <img width="846" alt="image" src="https://github.com/grimmpp/home-assistant-eltako/assets/46369917/96c44c86-2407-4c80-85f1-4668975d3148">

# Testing

Testing this integration via Home Assistant development container or updating it in a Home Assistant instance is quite time consuming. Therefore I've added some basic tests to ensure quickly a base quality.
Expand Down Expand Up @@ -158,4 +164,4 @@ In general, you can contribute to this project by:
Thanks to [chrysn](https://gitlab.com/chrysn) and [Johannes Bosecker](https://github.com/JBosecker) who initiated and made the first version of this code publicly available on their Gitlab repos, and shared it in the Home Assistant community ([Eltako “Baureihe 14 – RS485” (Enocean) Debugging](https://community.home-assistant.io/t/eltako-baureihe-14-rs485-enocean-debugging)). <br />
This fork was decoupled because of many many fundamental changes to the original repository. <br/>
Big thanks as well to [Cedric Van Labeke](https://github.com/cvanlabe) who provides a very good [documentation](https://github.com/cvanlabe/Eltako-home-automation/tree/main) and helped me to make my first steps into this world. <br />
Thanks to [LHBL2003](https://github.com/LHBL2003) who is eagerly testing and pushing things to a good quality by creating Pull Requests and Issues.
Thanks to [LHBL2003](https://github.com/LHBL2003) who is eagerly testing and pushing things to a good quality by creating Pull Requests and Issues.
22 changes: 17 additions & 5 deletions custom_components/eltako/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,31 @@ def value_changed(self, msg):
elif decoded.time is not None and decoded.direction is not None and self._time_closes is not None and self._time_opens is not None:

time_in_seconds = decoded.time / 10.0

if decoded.direction == 0x01: # up

if decoded.direction == 0x01: # up
# If the latest state is unknown, the cover position
# will be set to None, therefore we have to guess
# the initial position.
if self._attr_current_cover_position is None:
self._attr_current_cover_position = 0

self._attr_current_cover_position = min(self._attr_current_cover_position + int(time_in_seconds / self._time_opens * 100.0), 100)
self._attr_is_opening = True
self._attr_is_closing = False
self._attr_is_closed = None

else: # down

else: # down
# If the latest state is unknown, the cover position
# will be set to None, therefore we have to guess
# the initial position.
if self._attr_current_cover_position is None:
self._attr_current_cover_position = 100

self._attr_current_cover_position = max(self._attr_current_cover_position - int(time_in_seconds / self._time_closes * 100.0), 0)
self._attr_is_opening = False
self._attr_is_closing = True
self._attr_is_closed = None

if self._attr_current_cover_position == 0:
self._attr_is_closed = True
self._attr_is_opening = False
Expand Down
2 changes: 1 addition & 1 deletion custom_components/eltako/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ def value_changed(self, msg: ESP2Message):
LOGGER.warning("[Target Temperature Sensor %s] Could not decode message: %s", self.dev_id, str(e))
return

self._attr_target_temperature = round( 2*decoded.target_temperature, 0)/2
self._attr_native_value = round(2 * decoded.target_temperature, 0) / 2

self.schedule_update_ha_state()

Expand Down

0 comments on commit 2fbbfa3

Please sign in to comment.