Skip to content

Commit

Permalink
Changed Error State Entity Category + Added Error Message Sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
efipso committed Aug 18, 2024
1 parent 280c18b commit ef2da07
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 6 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ It's done basically for my own use.

## Changelog

v1.4
- Added Error Message sensor
- Changed Error State Entity Category
- Changed WIFI Signal Strength Entity Category

v1.3
- Added Error State sensor

Expand Down
4 changes: 3 additions & 1 deletion custom_components/melcloud_custom/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
BinarySensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry

from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

Expand All @@ -34,6 +34,7 @@ class MelcloudBinarySensorEntityDescription(BinarySensorEntityDescription):
key="error_state",
translation_key="error_state",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda x: x.device.has_error,
enabled=lambda x: True,
),
Expand All @@ -43,6 +44,7 @@ class MelcloudBinarySensorEntityDescription(BinarySensorEntityDescription):
key="error_state",
translation_key="error_state",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda x: x.device.has_error,
enabled=lambda x: True,
),
Expand Down
16 changes: 12 additions & 4 deletions custom_components/melcloud_custom/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@
},
"wifi_signal": {
"default": "mdi:wifi"
},
"error_message": {
"default": "mdi:message-alert"
}
},
"binary_sensor": {
"error_state": {
"default": "mdi:alert"
}
},
"services": {
"set_vane_horizontal": "mdi:arrow-left-right",
"set_vane_vertical": "mdi:arrow-up-down"
}
},
"services": {
"set_vane_horizontal": "mdi:arrow-left-right",
"set_vane_vertical": "mdi:arrow-up-down"
}
}
2 changes: 1 addition & 1 deletion custom_components/melcloud_custom/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"documentation": "https://github.com/efipso/melcloud",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/efipso/melcloud/issues",
"version": "1.3"
"version": "1.4"
}
17 changes: 17 additions & 0 deletions custom_components/melcloud_custom/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
UnitOfEnergy,
UnitOfTemperature,
EntityCategory,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand Down Expand Up @@ -69,10 +70,18 @@ class MelcloudSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda x: x.device.wifi_signal,
enabled=lambda x: True,
entity_registry_enabled_default=False,
),
MelcloudSensorEntityDescription(
key="error_message",
translation_key="error_message",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda x: x.device.error_code if x.device.has_error else 'No error',
enabled=lambda x: True,
),
)
ATW_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
MelcloudSensorEntityDescription(
Expand All @@ -99,10 +108,18 @@ class MelcloudSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda x: x.device.wifi_signal,
enabled=lambda x: True,
entity_registry_enabled_default=False,
),
MelcloudSensorEntityDescription(
key="error_message",
translation_key="error_message",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda x: x.device.error_code if x.device.has_error else 'No error',
enabled=lambda x: True,
),
)
ATW_ZONE_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
MelcloudSensorEntityDescription(
Expand Down
3 changes: 3 additions & 0 deletions custom_components/melcloud_custom/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
},
"wifi_signal": {
"name": "Wifi Signal Strength"
},
"error_message": {
"name": "Error Message"
}
},
"binary_sensor": {
Expand Down
5 changes: 5 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ It's done basically for my own use.

## Changelog

v1.4
- Added Error Message sensor
- Changed Error State Entity Category
- Changed WIFI Signal Strength Entity Category

v1.3
- Added Error State sensor

Expand Down

0 comments on commit ef2da07

Please sign in to comment.