Skip to content

Commit

Permalink
Move enki setpower after onoff to onoff_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 committed Feb 17, 2024
1 parent 58277ed commit f2b18f0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 50 deletions.
43 changes: 9 additions & 34 deletions Modules/enki.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,19 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: zaraki673 & pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

from Modules.basicOutputs import set_poweron_afteroffon
from Modules.readAttributes import ReadAttributeRequest_0006_400x

ENKI_POWERON_MODE = {0x00: "Off", 0x01: "On", 0xFF: "Previous state"} # Off # On # Previous state

def is_enky_device(self, nwkid):
return self.ListOfDevices[nwkid]["Manufacturer"] == "1277"


def enki_set_poweron_after_offon(self, mode):
# call from WebServer

if mode not in ENKI_POWERON_MODE:
self.log.logging("Enki", "Error", "enki_set_poweron_after_offon - Unknown mode: %s" % mode)

for nwkid in self.ListOfDevices:
enki_set_poweron_after_offon_device(self, mode, nwkid)


def enki_set_poweron_after_offon_device(self, mode, nwkid):
if "Manufacturer" not in self.ListOfDevices[nwkid]:
return
if self.ListOfDevices[nwkid]["Manufacturer"] != "1277":
return
# We have a Enki device
if "01" not in self.ListOfDevices[nwkid]["Ep"]:
return
if "0006" not in self.ListOfDevices[nwkid]["Ep"]["01"]:
return
if "4003" not in self.ListOfDevices[nwkid]["Ep"]["01"]["0006"]:
self.log.logging("Enki", "Debug", "enki_set_poweron_after_offon Device: %s do not have a Set Power Attribute !" % nwkid)
ReadAttributeRequest_0006_400x(self, nwkid)
return

# At that stage, we have a Philips device with Cluster 0006 and the right attribute
self.log.logging("Enki", "Debug", "enki_set_poweron_after_offon - Set PowerOn after OffOn of %s to %s" % (
nwkid, ENKI_POWERON_MODE[mode]) )
set_poweron_afteroffon(self, nwkid, OnOffMode=mode)
ReadAttributeRequest_0006_400x(self, nwkid)
6 changes: 0 additions & 6 deletions Modules/ias_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
# SPDX-License-Identifier: GPL-3.0 license

from Modules.basicOutputs import write_attribute
from Modules.enki import enki_set_poweron_after_offon_device, is_enky_device
from Modules.philips import is_philips_device
from Modules.readAttributes import ReadAttributeRequest_0006_400x
from Modules.tools import get_deviceconf_parameter_value, getListOfEpForCluster
from Modules.tuya import (get_tuya_attribute, is_tuya_switch_relay,
tuya_switch_relay_status)
from Modules.zigateConsts import ZIGATE_EP

IAS_CLUSTER_ID = "0500"
Expand Down
7 changes: 3 additions & 4 deletions Modules/onoff_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# SPDX-License-Identifier: GPL-3.0 license

from Modules.basicOutputs import write_attribute
from Modules.enki import enki_set_poweron_after_offon_device, is_enky_device
from Modules.enki import is_enky_device
from Modules.philips import is_philips_device
from Modules.readAttributes import ReadAttributeRequest_0006_400x
from Modules.tools import get_deviceconf_parameter_value, getListOfEpForCluster
Expand Down Expand Up @@ -135,12 +135,11 @@ def common_onoff_startup_onoff_mode(self, nwkid, mode):
ListOfEp = ["0b",]

elif is_enky_device(self, nwkid): # Enki Leroy Merlin
enki_set_poweron_after_offon_device(self, mode, nwkid)
return
ListOfEp = ["01",]

elif is_tuya_switch_relay(self, nwkid):
if get_tuya_attribute(self, nwkid, "RelayStatus") != mode:
tuya_switch_relay_status(self, nwkid, mode)
tuya_switch_relay_status(self, nwkid, status=mode)
return

else:
Expand Down
6 changes: 0 additions & 6 deletions Modules/paramDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
#
# SPDX-License-Identifier: GPL-3.0 license

"""
Module: paramDevice.py
Description: implement the parameter device specific
"""

from DevicesModules.custom_sonoff import SONOFF_DEVICE_PARAMETERS
from Modules.basicOutputs import (ballast_Configuration_max_level,
Expand Down

0 comments on commit f2b18f0

Please sign in to comment.