Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aneisch committed Apr 5, 2023
1 parent 381e85e commit dc0b724
Show file tree
Hide file tree
Showing 22 changed files with 313 additions and 205 deletions.
59 changes: 29 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Build Status](https://github.com/aneisch/home-assistant-config/actions/workflows/check-ha-release-compatibility.yml/badge.svg)](https://github.com/aneisch/home-assistant-config/actions)
[![GitHub last commit](https://img.shields.io/github/last-commit/aneisch/home-assistant-config)](https://github.com/aneisch/home-assistant-config/commits/master)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/aneisch/home-assistant-config)](https://github.com/aneisch/home-assistant-config/graphs/commit-activity)
[![HA Version](https://img.shields.io/badge/Running%20Home%20Assistant-2023.3.6%20(Latest)-brightgreen)](https://github.com/home-assistant/home-assistant/releases/latest)
[![HA Version](https://img.shields.io/badge/Running%20Home%20Assistant%20-2023.4.0b6%20(Out%20of%20Date)-Red)](https://github.com/home-assistant/home-assistant/releases/latest)
<br><a href="https://www.buymeacoffee.com/aneisch" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-black.png" width="150px" height="35px" alt="Buy Me A Coffee" style="height: 35px !important;width: 150px !important;" ></a>


Expand All @@ -18,7 +18,6 @@ My Home Assistant installation contains many different components and runs on a
- Milights with [Homebrew MiLight controller](http://blog.christophermullins.com/2017/02/11/milight-wifi-gateway-emulator-on-an-esp8266/) using D1 Mini and NRF24L01.
- Wemo wall plugs
- ZHA using [CC2531](https://amzn.to/2L5xKNB) running zigbee2mqtt firmware with various devices
_ZIGBEEDEVICES_
- [Lustreon E27](https://www.banggood.com/LUSTREON-E27-Smart-WiFi-Bulb-Adapter-Socket-Lamp-Holder-Work-With-Alexa-Google-Home-IFTTT-AC85-265V-p-1285550.html) bulb holders for lamp control using ~~Tasmota/MQTT~~ ESPHome (1MB flash)
- Check out [my blog post](http://blog.aneis.ch/2019/01/tuya-convert-for-lustreon.html) for alternative firmware flashing instructions
- Z-Wave JS using [Aeon Labs USB stick](https://amzn.to/39cmb1b) with various devices
Expand Down Expand Up @@ -65,43 +64,43 @@ Z-Wave devices in [`zwave_js`](https://www.home-assistant.io/integrations/zwave_

Description | value
-- | --
Entities in the [`alarm_control_panel`](https://www.home-assistant.io/components/alarm_control_panel) domain | 3
Entities in the [`automation`](https://www.home-assistant.io/components/automation) domain | 86
Entities in the [`binary_sensor`](https://www.home-assistant.io/components/binary_sensor) domain | 87
Entities in the [`button`](https://www.home-assistant.io/components/button) domain | 64
Entities in the [`calendar`](https://www.home-assistant.io/components/calendar) domain | 1
Entities in the [`camera`](https://www.home-assistant.io/components/camera) domain | 15
Entities in the [`climate`](https://www.home-assistant.io/components/climate) domain | 1
Entities in the [`counter`](https://www.home-assistant.io/components/counter) domain | 1
Entities in the [`cover`](https://www.home-assistant.io/components/cover) domain | 5
Entities in the [`device_tracker`](https://www.home-assistant.io/components/device_tracker) domain | 4
Entities in the [`fan`](https://www.home-assistant.io/components/fan) domain | 3
Entities in the [`person`](https://www.home-assistant.io/components/person) domain | 2
Entities in the [`setter`](https://www.home-assistant.io/components/setter) domain | 1
Entities in the [`plant`](https://www.home-assistant.io/components/plant) domain | 1
Entities in the [`group`](https://www.home-assistant.io/components/group) domain | 13
Entities in the [`input_boolean`](https://www.home-assistant.io/components/input_boolean) domain | 24
Entities in the [`input_datetime`](https://www.home-assistant.io/components/input_datetime) domain | 31
Entities in the [`zone`](https://www.home-assistant.io/components/zone) domain | 6
Entities in the [`timer`](https://www.home-assistant.io/components/timer) domain | 1
Entities in the [`counter`](https://www.home-assistant.io/components/counter) domain | 1
Entities in the [`sun`](https://www.home-assistant.io/components/sun) domain | 1
Entities in the [`input_number`](https://www.home-assistant.io/components/input_number) domain | 4
Entities in the [`input_select`](https://www.home-assistant.io/components/input_select) domain | 19
Entities in the [`input_text`](https://www.home-assistant.io/components/input_text) domain | 4
Entities in the [`input_select`](https://www.home-assistant.io/components/input_select) domain | 19
Entities in the [`input_boolean`](https://www.home-assistant.io/components/input_boolean) domain | 24
Entities in the [`input_datetime`](https://www.home-assistant.io/components/input_datetime) domain | 31
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 338
Entities in the [`scene`](https://www.home-assistant.io/components/scene) domain | 2
Entities in the [`light`](https://www.home-assistant.io/components/light) domain | 38
Entities in the [`lock`](https://www.home-assistant.io/components/lock) domain | 2
Entities in the [`automation`](https://www.home-assistant.io/components/automation) domain | 86
Entities in the [`alarm_control_panel`](https://www.home-assistant.io/components/alarm_control_panel) domain | 3
Entities in the [`script`](https://www.home-assistant.io/components/script) domain | 37
Entities in the [`weather`](https://www.home-assistant.io/components/weather) domain | 2
Entities in the [`media_player`](https://www.home-assistant.io/components/media_player) domain | 12
Entities in the [`vacuum`](https://www.home-assistant.io/components/vacuum) domain | 1
Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 149
Entities in the [`camera`](https://www.home-assistant.io/components/camera) domain | 15
Entities in the [`binary_sensor`](https://www.home-assistant.io/components/binary_sensor) domain | 84
Entities in the [`button`](https://www.home-assistant.io/components/button) domain | 64
Entities in the [`cover`](https://www.home-assistant.io/components/cover) domain | 5
Entities in the [`lock`](https://www.home-assistant.io/components/lock) domain | 2
Entities in the [`number`](https://www.home-assistant.io/components/number) domain | 55
Entities in the [`person`](https://www.home-assistant.io/components/person) domain | 2
Entities in the [`plant`](https://www.home-assistant.io/components/plant) domain | 1
Entities in the [`scene`](https://www.home-assistant.io/components/scene) domain | 2
Entities in the [`script`](https://www.home-assistant.io/components/script) domain | 37
Entities in the [`select`](https://www.home-assistant.io/components/select) domain | 20
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 335
Entities in the [`setter`](https://www.home-assistant.io/components/setter) domain | 1
Entities in the [`fan`](https://www.home-assistant.io/components/fan) domain | 3
Entities in the [`device_tracker`](https://www.home-assistant.io/components/device_tracker) domain | 4
Entities in the [`siren`](https://www.home-assistant.io/components/siren) domain | 1
Entities in the [`sun`](https://www.home-assistant.io/components/sun) domain | 1
Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 152
Entities in the [`timer`](https://www.home-assistant.io/components/timer) domain | 1
Entities in the [`calendar`](https://www.home-assistant.io/components/calendar) domain | 1
Entities in the [`climate`](https://www.home-assistant.io/components/climate) domain | 1
Entities in the [`update`](https://www.home-assistant.io/components/update) domain | 25
Entities in the [`vacuum`](https://www.home-assistant.io/components/vacuum) domain | 1
Entities in the [`weather`](https://www.home-assistant.io/components/weather) domain | 2
Entities in the [`zone`](https://www.home-assistant.io/components/zone) domain | 6
**Total state objects** | **1059**
**Total state objects** | **1056**
## The HACS integrations/plugins that I use:
**Appdaemon**:<br>
[aneisch/follow_me_appdaemon](https://github.com/aneisch/follow_me_appdaemon)<br>
Expand Down
14 changes: 7 additions & 7 deletions configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ recorder:

rest_command: !include rest_command.yaml

samsungtv:
- host: 10.0.1.51
name: Living Room TV
turn_on_action:
- service: wake_on_lan.send_magic_packet
data:
mac: 44:5c:e9:2e:51:0a
# samsungtv:
# - host: 10.0.1.51
# name: Living Room TV
# turn_on_action:
# - service: wake_on_lan.send_magic_packet
# data:
# mac: 44:5c:e9:2e:51:0a

scene: !include scene.yaml

Expand Down
42 changes: 26 additions & 16 deletions custom_components/sonoff/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class XClimateNS(XEntity, ClimateEntity):
_attr_hvac_modes = [HVAC_MODE_OFF, HVAC_MODE_HEAT_COOL, HVAC_MODE_AUTO]
_attr_max_temp = 31
_attr_min_temp = 16
_attr_supported_features = SUPPORT_TARGET_TEMPERATURE
_attr_temperature_unit = TEMP_CELSIUS
_attr_target_temperature_step = 1

Expand All @@ -159,23 +160,19 @@ def set_state(self, params: dict):
cache.update(params)

if "HMI_ATCDevice" in params and "etype" in params["HMI_ATCDevice"]:
self._attr_hvac_modes[1] = (
HVAC_MODE_COOL
if cache["HMI_ATCDevice"]["etype"] == "cold"
else HVAC_MODE_HEAT
)
if cache["HMI_ATCDevice"]["etype"] == "cold":
self._attr_hvac_modes[1] = HVAC_MODE_COOL
else:
self._attr_hvac_modes[1] = HVAC_MODE_HEAT

if "ATCEnable" in params or "ATCMode" in params:
if cache["ATCEnable"]:
if cache["ATCMode"]:
self._attr_hvac_mode = HVAC_MODE_AUTO
self._attr_supported_features = 0
self.set_hvac_attr(HVAC_MODE_AUTO)
else:
self._attr_hvac_mode = self.hvac_modes[1]
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE
self.set_hvac_attr(self._attr_hvac_modes[1])
else:
self._attr_hvac_mode = HVAC_MODE_OFF
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE
self.set_hvac_attr(HVAC_MODE_OFF)

if "ATCExpect0" in params:
self._attr_target_temperature = cache["ATCExpect0"]
Expand All @@ -190,11 +187,22 @@ def set_state(self, params: dict):
except:
pass

def set_hvac_attr(self, hvac_mode: str) -> None:
if hvac_mode == HVAC_MODE_AUTO:
self._attr_hvac_mode = hvac_mode
self._attr_supported_features = 0
elif hvac_mode == HVAC_MODE_OFF:
self._attr_hvac_mode = hvac_mode
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE
elif hvac_mode in (HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL):
self._attr_hvac_mode = self._attr_hvac_modes[1]
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE

@staticmethod
def get_params(hvac_mode: str) -> dict:
if hvac_mode == HVAC_MODE_AUTO:
return {"ATCEnable": 1, "ATCMode": 1}
elif hvac_mode in (HVAC_MODE_HEAT_COOL, HVAC_MODE_HEAT):
elif hvac_mode in (HVAC_MODE_COOL, HVAC_MODE_HEAT):
return {"ATCEnable": 1, "ATCMode": 0}
elif hvac_mode == HVAC_MODE_HEAT_COOL:
return {"ATCEnable": 1} # async_turn_on
Expand All @@ -210,11 +218,13 @@ async def async_set_hvac_mode(self, hvac_mode: str) -> None:
async def async_set_temperature(
self, temperature: float = None, hvac_mode: str = None, **kwargs
) -> None:
params = self.get_params(hvac_mode)
if temperature is not None:
params["ATCExpect0"] = temperature
if not params:
params["ATCEnable"] = 1
# https://github.com/AlexxIT/SonoffLAN/issues/1107
params = {"ATCMode": 0, "ATCExpect0": temperature}
elif hvac_mode is not None:
params = self.get_params(hvac_mode)
else:
params = {"ATCEnable": 1}
await self.ewelink.cloud.send(self.device, params)


Expand Down
119 changes: 70 additions & 49 deletions custom_components/sonoff/core/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@
XUnknown,
XWiFiDoorBattery,
XEnergySensorDualR3,
XEnergySensorPOWR3,
)
from ..switch import (
XSwitch,
XSwitches,
XSwitchTH,
XToggle,
XZigbeeSwitches,
XSwitchPOWR3,
)
from ..switch import XSwitch, XSwitches, XSwitchTH, XToggle, XZigbeeSwitches

# supported custom device_class
DEVICE_CLASS = {
Expand Down Expand Up @@ -109,29 +117,12 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
Power2 = spec(XSensor100, param="actPow_01", uid="power_2")
Power3 = spec(XSensor100, param="actPow_02", uid="power_3")
Power4 = spec(XSensor100, param="actPow_03", uid="power_4")
Energy1 = spec(
XEnergySensor, param="kwhHistories_00", uid="energy_1", get_params={"getKwh_00": 2}
)
Energy2 = spec(
XEnergySensor, param="kwhHistories_01", uid="energy_2", get_params={"getKwh_01": 2}
)
Energy3 = spec(
XEnergySensor, param="kwhHistories_01", uid="energy_3", get_params={"getKwh_02": 2}
)
Energy4 = spec(
XEnergySensor, param="kwhHistories_01", uid="energy_4", get_params={"getKwh_03": 2}
)
Energy1_DualR3 = spec(
XEnergySensorDualR3,
param="kwhHistories_00",
uid="energy_1",
get_params={"getKwh_00": 2},
)
Energy2_DualR3 = spec(
XEnergySensorDualR3,
param="kwhHistories_01",
uid="energy_2",
get_params={"getKwh_01": 2},

EnergyPOW = spec(
XEnergySensor,
param="hundredDaysKwhData",
uid="energy",
get_params={"hundredDaysKwh": "get"},
)

# https://github.com/CoolKit-Technologies/eWeLink-API/blob/main/en/UIIDProtocol.md
Expand All @@ -145,12 +136,7 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
LED,
RSSI,
spec(XSensor, param="power"),
spec(
XEnergySensor,
param="hundredDaysKwhData",
uid="energy",
get_params={"hundredDaysKwh": "get"},
),
EnergyPOW,
], # Sonoff POW (first)
6: SPEC_SWITCH,
7: SPEC_2CH, # Sonoff T1 2CH
Expand Down Expand Up @@ -192,12 +178,7 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
spec(XSensor, param="current"),
spec(XSensor, param="power"),
spec(XSensor, param="voltage"),
spec(
XEnergySensor,
param="hundredDaysKwhData",
uid="energy",
get_params={"hundredDaysKwh": "get"},
),
EnergyPOW,
], # Sonoff POWR2
33: [XLightL1, RSSI], # https://github.com/AlexxIT/SonoffLAN/issues/985
34: [
Expand Down Expand Up @@ -231,8 +212,18 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
Voltage2,
Power1,
Power2,
Energy1_DualR3,
Energy2_DualR3,
spec(
XEnergySensorDualR3,
param="kwhHistories_00",
uid="energy_1",
get_params={"getKwh_00": 2},
),
spec(
XEnergySensorDualR3,
param="kwhHistories_01",
uid="energy_2",
get_params={"getKwh_01": 2},
),
], # Sonoff DualR3
127: [XThermostat], # https://github.com/AlexxIT/SonoffLAN/issues/358
128: [LED], # SPM-Main
Expand All @@ -253,10 +244,30 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
Power2,
Power3,
Power4,
Energy1,
Energy2,
Energy3,
Energy4,
spec(
XEnergySensorDualR3,
param="kwhHistories_00",
uid="energy_1",
get_params={"getKwh_00": 2},
),
spec(
XEnergySensorDualR3,
param="kwhHistories_01",
uid="energy_2",
get_params={"getKwh_01": 2},
),
spec(
XEnergySensorDualR3,
param="kwhHistories_01",
uid="energy_3",
get_params={"getKwh_02": 2},
),
spec(
XEnergySensorDualR3,
param="kwhHistories_01",
uid="energy_4",
get_params={"getKwh_03": 2},
),
], # SPM-4Relay, https://github.com/AlexxIT/SonoffLAN/issues/658
133: [
# Humidity. ALWAYS 50... NSPanel DOESN'T HAVE HUMIDITY SENSOR
Expand All @@ -270,7 +281,10 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
# https://github.com/AlexxIT/SonoffLAN/issues/1026
135: [XLightB02, RSSI], # Sonoff B02-BL
# https://github.com/AlexxIT/SonoffLAN/issues/766
136: [XLightB05B, RSSI], # Sonoff B05-BL
# https://github.com/AlexxIT/SonoffLAN/issues/890
# https://github.com/AlexxIT/SonoffLAN/pull/892
# https://github.com/AlexxIT/SonoffLAN/pull/1035
136: [spec(XLightB05B, min_ct=0, max_ct=100), RSSI], # Sonoff B05-BL
137: [XLightL1, RSSI],
# https://github.com/AlexxIT/SonoffLAN/issues/623#issuecomment-1365841454
138: SPEC_1CH, # MINIR3
Expand All @@ -285,7 +299,6 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
177: [XRemoteButton], # Sonoff S-Mate
181: [
XSwitchTH,
XClimateTH,
XTemperatureTH,
XHumidityTH,
LED,
Expand All @@ -298,19 +311,22 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
spec(XSensor, param="current"),
spec(XSensor, param="power"),
spec(XSensor, param="voltage"),
EnergyPOW,
], # Sonoff S40
190: [
Switch1,
XSwitchPOWR3,
LED,
RSSI,
spec(XSensor100, param="current"),
spec(XSensor100, param="power"),
spec(XSensor100, param="voltage"),
spec(XSensor100, param="dayKwh", uid="energy_day"),
spec(XSensor100, param="monthKwh", uid="energy_month"),
spec(
XEnergySensor,
param="hundredDaysKwhData",
XEnergySensorPOWR3,
param="hoursKwhData",
uid="energy",
get_params={"hundredDaysKwh": "get"},
get_params={"getHoursKwh": {"start": 0, "end": 24 * 30 - 1}},
),
], # Sonoff POWR3
1000: [XRemoteButton, Battery], # zigbee_ON_OFF_SWITCH_1000
Expand All @@ -323,6 +339,11 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
spec(XSensor100, param="humidity"),
Battery,
], # ZCL_HA_DEVICEID_TEMPERATURE_SENSOR
1771: [
spec(XSensor100, param="temperature"),
spec(XSensor100, param="humidity"),
Battery,
], # https://github.com/AlexxIT/SonoffLAN/issues/1150
2026: [XZigbeeMotion, Battery], # ZIGBEE_MOBILE_SENSOR
# ZIGBEE_DOOR_AND_WINDOW_SENSOR
3026: [
Expand Down Expand Up @@ -440,7 +461,7 @@ def set_default_class(device_class: str):
# DIY type, UIID, Brand, Model/Name
"plug": [1, None, "Single Channel DIY"], # POWR316
"strip": [4, None, "Multi Channel DIY"], # 4CHPROR3
"diy_plug": [1, "SONOFF", "MINI DIY"],
"diy_plug": [138, "SONOFF", "MINI DIY"],
"enhanced_plug": [5, "SONOFF", "POW DIY"], # POWR2
"th_plug": [15, "SONOFF", "TH DIY"], # TH16R2
"rf": [28, "SONOFF", "RFBridge DIY"],
Expand Down
Loading

0 comments on commit dc0b724

Please sign in to comment.