Skip to content

Commit

Permalink
Added indoor humidity sensor support
Browse files Browse the repository at this point in the history
  • Loading branch information
paveldn committed Dec 27, 2023
1 parent 4d41d9c commit 87e05a1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .haier-hon-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ packages:
# Horizontal airflow direction setting. Works only if the horizontal swing
# is off. You can remove this control if you don't need it
airflow_horizontal_select: !include configs/select/airflow_horizontal.yaml
# Diagnostic sensors
# Additional sensors
outdoor_temperature_sensor: !include configs/sensor/outdoor_temperature.yaml
# Make sure that your AC supports humidity before uncommenting it
# (in the opposite case value will always be 0)
#indoor_humidity_sensor: !include configs/sensor/humidity.yaml
# Diagnostic sensors
indoor_coil_temperature_sensor: !include configs/sensor/indoor_coil_temperature.yaml
outdoor_coil_temperature_sensor: !include configs/sensor/outdoor_coil_temperature.yaml
outdoor_defrost_temperature_sensor: !include configs/sensor/outdoor_defrost_temperature.yaml
Expand Down
3 changes: 3 additions & 0 deletions components/haier/hon_climate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,9 @@ haier_protocol::HandlerError HonClimate::process_status_message_(const uint8_t *
this->got_valid_outdoor_temp_ = true;
this->update_sub_sensor(SubSensorType::OUTDOOR_TEMPERATURE, (float) (packet.sensors.outdoor_temperature + PROTOCOL_OUTDOOR_TEMPERATURE_OFFSET));
}
if ((this->sub_sensors_[(size_t)SubSensorType::HUMIDITY] != nullptr) && (packet.sensors.room_humidity <= 100)) {
this->update_sub_sensor(SubSensorType::HUMIDITY, (float) packet.sensors.room_humidity);
}
#endif // USE_SENSOR
bool should_publish = false;
{
Expand Down
1 change: 1 addition & 0 deletions components/haier/hon_climate.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class HonClimate : public HaierClimateBase {
enum class SubSensorType {
// Used data based sensors
OUTDOOR_TEMPERATURE = 0,
HUMIDITY,
// Big data based sensors
INDOOR_COIL_TEMPERATURE,
OUTDOOR_COIL_TEMPERATURE,
Expand Down
10 changes: 10 additions & 0 deletions components/haier/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
from esphome.components import sensor
from esphome.const import (
CONF_POWER,
CONF_HUMIDITY,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_FREQUENCY,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_POWER,
DEVICE_CLASS_TEMPERATURE,
ENTITY_CATEGORY_DIAGNOSTIC,
Expand All @@ -14,6 +16,7 @@
ICON_HEATING_COIL,
ICON_PULSE,
ICON_THERMOMETER,
ICON_WATER_PERCENT,
ICON_WEATHER_WINDY,
STATE_CLASS_MEASUREMENT,
UNIT_AMPERE,
Expand Down Expand Up @@ -69,6 +72,13 @@
state_class=STATE_CLASS_MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
CONF_HUMIDITY: sensor.sensor_schema(
unit_of_measurement=UNIT_PERCENT,
icon=ICON_WATER_PERCENT,
accuracy_decimals=0,
device_class=DEVICE_CLASS_HUMIDITY,
state_class=STATE_CLASS_MEASUREMENT,
),
CONF_INDOOR_COIL_TEMPERATURE: sensor.sensor_schema(
unit_of_measurement=UNIT_CELSIUS,
icon=ICON_HEATING_COIL,
Expand Down
5 changes: 5 additions & 0 deletions configs/sensor/humidity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sensor:
- platform: haier
haier_id: ${device_id}
humidity:
name: ${device_name} Indoor Humidity

0 comments on commit 87e05a1

Please sign in to comment.