Skip to content

Commit

Permalink
implement BatteryPercentage widget
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 committed Aug 5, 2024
1 parent 69a36f9 commit 5edb7ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Modules/domoCreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,12 @@ def set_default_value( self, Devices, device_id_ieee, device_unit, widget_record
"Type": 243,
"Subtype": 19
},
"BatteryPercentage": {
"Type": 243,
"Subtype": 6,
"Switchtype": 0
},

"P1Meter": {
"Type": 250,
"Subtype": 1,
Expand Down
6 changes: 5 additions & 1 deletion Modules/domoMaj.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ def _domo_maj_one_cluster_type_entry( self, Devices, NwkId, Ep, device_id_ieee,
nValue = int(value)
update_domoticz_widget(self, Devices, device_id_ieee, device_unit, nValue, text, BatteryLevel, SignalLevel)

if WidgetType == "BatteryPercentage" and ClusterType == "Voltage" and Attribute_ == "0021":
sValue = str(nValue)
update_domoticz_widget(self, Devices, device_id_ieee, device_unit, 0, sValue, BatteryLevel, SignalLevel)

if ClusterType == "Alarm" and WidgetType == "Alarm_ZL3" and Attribute_ == "0020":
if value is None or len(value) == 0:
return
Expand Down Expand Up @@ -532,7 +536,7 @@ def _domo_maj_one_cluster_type_entry( self, Devices, NwkId, Ep, device_id_ieee,
update_domoticz_widget(self, Devices, device_id_ieee, device_unit, int(data), str(state), BatteryLevel, SignalLevel, ForceUpdate_=True)

if "Valve" in ClusterType and (WidgetType == "Valve" and Attribute_ in ("026d", "4001", "0008")):
nValue = round(value, 1)
nValue = 0
sValue = str(nValue)
update_domoticz_widget(self, Devices, device_id_ieee, device_unit, nValue, sValue, BatteryLevel, SignalLevel)

Expand Down
1 change: 1 addition & 0 deletions Modules/tuyaTS0601.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def ts0601_battery(self, Devices, nwkid, ep, value ):
checkAndStoreAttributeValue(self, nwkid, "01", "0001", "0000", value)
self.ListOfDevices[nwkid]["Battery"] = value
Update_Battery_Device(self, Devices, nwkid, value)
MajDomoDevice(self, Devices, nwkid, ep, "0001", "0021", value)
store_tuya_attribute(self, nwkid, "BatteryStatus", value)


Expand Down

0 comments on commit 5edb7ad

Please sign in to comment.