Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wallswitch support to enocean #86461

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 51 additions & 5 deletions homeassistant/components/enocean/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
SENSOR_TYPE_POWER = "powersensor"
SENSOR_TYPE_TEMPERATURE = "temperature"
SENSOR_TYPE_WINDOWHANDLE = "windowhandle"
SENSOR_TYPE_WALLSWITCH = "wallswitch"


@dataclass
Expand Down Expand Up @@ -96,6 +97,13 @@ class EnOceanSensorEntityDescription(
unique_id=lambda dev_id: f"{combine_hex(dev_id)}-{SENSOR_TYPE_WINDOWHANDLE}",
)

SENSOR_DESC_WALLSWITCH = EnOceanSensorEntityDescription(
key=SENSOR_TYPE_WALLSWITCH,
name="WallSwitch",
icon="mdi:widgets-outline",
unique_id=lambda dev_id: f"{combine_hex(dev_id)}-{SENSOR_TYPE_WALLSWITCH}",
)


PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
Expand Down Expand Up @@ -148,6 +156,9 @@ def setup_platform(
elif sensor_type == SENSOR_TYPE_WINDOWHANDLE:
entities = [EnOceanWindowHandle(dev_id, dev_name, SENSOR_DESC_WINDOWHANDLE)]

elif sensor_type == SENSOR_TYPE_WALLSWITCH:
entities = [EnOceanWallSwitch(dev_id, dev_name, SENSOR_DESC_WALLSWITCH)]

add_entities(entities)


Expand Down Expand Up @@ -177,7 +188,6 @@ def value_changed(self, packet):

class EnOceanPowerSensor(EnOceanSensor):
"""Representation of an EnOcean power sensor.

EEPs (EnOcean Equipment Profiles):
- A5-12-01 (Automated Meter Reading, Electricity)
"""
Expand All @@ -197,7 +207,6 @@ def value_changed(self, packet):

class EnOceanTemperatureSensor(EnOceanSensor):
"""Representation of an EnOcean temperature sensor device.

EEPs (EnOcean Equipment Profiles):
- A5-02-01 to A5-02-1B All 8 Bit Temperature Sensors of A5-02
- A5-10-01 to A5-10-14 (Room Operating Panels)
Expand All @@ -206,7 +215,6 @@ class EnOceanTemperatureSensor(EnOceanSensor):
- A5-10-10 (Temp. and Humidity Sensor and Set Point)
- A5-10-12 (Temp. and Humidity Sensor, Set Point and Occupancy Control)
- 10 Bit Temp. Sensors are not supported (A5-02-20, A5-02-30)

For the following EEPs the scales must be set to "0 to 250":
- A5-04-01
- A5-04-02
Expand Down Expand Up @@ -246,7 +254,6 @@ def value_changed(self, packet):

class EnOceanHumiditySensor(EnOceanSensor):
"""Representation of an EnOcean humidity sensor device.

EEPs (EnOcean Equipment Profiles):
- A5-04-01 (Temp. and Humidity Sensor, Range 0°C to +40°C and 0% to 100%)
- A5-04-02 (Temp. and Humidity Sensor, Range -20°C to +60°C and 0% to 100%)
Expand All @@ -264,7 +271,6 @@ def value_changed(self, packet):

class EnOceanWindowHandle(EnOceanSensor):
"""Representation of an EnOcean window handle device.

EEPs (EnOcean Equipment Profiles):
- F6-10-00 (Mechanical handle / Hoppe AG)
"""
Expand All @@ -281,3 +287,43 @@ def value_changed(self, packet):
self._attr_native_value = "tilt"

self.schedule_update_ha_state()


class EnOceanWallSwitch(EnOceanSensor):
"""Representation of an EnOcean wall switch.
EEPs (EnOcean Equipment Profiles):
- F6-02-00
"""

def value_changed(self, packet):
"""Update the internal state of the sensor."""
action = packet.data[1]

if action == 0xF0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This integration has existing code with protocol details that belong in a 3rd party library. We won't allow changes or additions that add more protocol details to the integration. The details need to be extracted to a 3rd party library published on PyPI first.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the windows handle are integrate like this but not the wall switch??? they are in the same family (rorg f6). I am not the first user how would like to see it in the dashboard.
So i don't understand your answers.
i am new user of HA, so what is Pypi?
i just not understand your answer
Best regards
image
EnOcean_Equipment_Profiles_EEP_V2.6.2_public.pdf

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to explain this above:

This integration has existing code with protocol details that belong in a 3rd party library. We won't allow changes or additions that add more protocol details to the integration.

The existing code is eg the window sensors you mention.

self._attr_native_value = STATE_CLOSED
if action in (0xE0, 0xC0):
self._attr_native_value = STATE_OPEN
if action == 0xD0:
self._attr_native_value = "tilt"
if action == 0x00:
self._attr_native_value = "release"
if action == 0x30:
self._attr_native_value = "BP1"
if action == 0x10:
self._attr_native_value = "BP2"
if action == 0x70:
self._attr_native_value = "BP3"
if action == 0x50:
self._attr_native_value = "BP4"
if action == 0x37:
self._attr_native_value = "BP1+3"
if action == 0x15:
self._attr_native_value = "BP2+4"
if action == 0x17:
self._attr_native_value = "BP2+3"
if action == 0x35:
self._attr_native_value = "BP1+4"
if action == 0x07:
self._attr_native_value = "shock"

self.schedule_update_ha_state()