Skip to content

Commit

Permalink
try a fix for #2
Browse files Browse the repository at this point in the history
  • Loading branch information
gluap committed May 5, 2019
1 parent cabe03d commit 7dffba4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ commands instead of buying a weather station.

Changelog
=========
**0.25.2**
- try to fix https://github.com/gluap/pyduofern/issues/2

**0.25.1**
- changed custom component to fix bug in switch implementation accidentally introduced
recently.
Expand Down
3 changes: 1 addition & 2 deletions examples/homeassistant/custom_components/duofern/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Import the device class from the component that you want to support

# Home Assistant depends on 3rd party packages for API specific code.
REQUIREMENTS = ['pyduofern==0.25']
REQUIREMENTS = ['pyduofern==0.25.2']

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -81,7 +81,6 @@ def clean_config(call):
hass.services.register(DOMAIN, 'sync_devices', sync_devices)
hass.services.register(DOMAIN, 'clean_config', clean_config)


def refresh(call):
_LOGGER.warning(call)
for _component in DUOFERN_COMPONENTS:
Expand Down
2 changes: 1 addition & 1 deletion pyduofern/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
__version__ = "0.25"
__version__ = "0.25.2"

__all__ = ['DuofernException', 'DuofernStick', 'DuofernStickAsync', 'duoACK']

Expand Down
16 changes: 8 additions & 8 deletions pyduofern/duofern.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,12 @@ def parse(self, msg):
if id not in sensorMsg:
logger.warning("unknown message {}".format(msg))

chan = msg[sensorMsg['id']['chan'] * 2 + 2:sensorMsg['id']['chan'] * 2 + 4]
chan = msg[sensorMsg[id]['chan'] * 2 + 2:sensorMsg[id]['chan'] * 2 + 4]
if code[0:2] in ("61", "70", "71"):
chan = "01"

chans = []
if (sensorMsg['id'][chan] == 5):
if (sensorMsg[id][chan] == 5):
chanCount = 4 if (code[0:2] == "73") else 5
for x in range(0, chanCount):
if ((0x01 << x) & int(chan, 16)):
Expand All @@ -545,19 +545,19 @@ def parse(self, msg):
for chan in chans:
if id[2:4] in ("1a", "18", "19", "01", "02", "03"):
if (id[2:4] == "1a") or (id[0:2] == "0e") or (code[0:2] in ("a0", "a2")):
self.update_state(code, "state", sensorMsg['id']['state'] + "." + chan, "1")
self.update_state(code, "state", sensorMsg[id]['state'] + "." + chan, "1")
else:
self.update_state(code, "state", sensorMsg['id']['state'], "1")
self.update_state(code, "state", sensorMsg[id]['state'], "1")

self.update_state(code, "channelchan", sensorMsg['id']['name'], "1")
self.update_state(code, "channelchan", sensorMsg[id]['name'], "1")
else:
if (code[0:2] not in ("69", "73")) or (id[2:4] in ("11", "12")):
chan = ""
if code[0:2] in ("65", "a5", "aa", "ab"):
self.update_state(code, "state", sensorMsg['id']['state'], "1")
self.update_state(code, "state", sensorMsg[id]['state'], "1")

self.update_state(code, "event", sensorMsg['id']['name'] + "." + chan, "1")
DoTrigger(hash["name"], sensorMsg['id'][name] + "." + chan)
self.update_state(code, "event", sensorMsg[id]['name'] + "." + chan, "1")
DoTrigger(hash["name"], sensorMsg[id][name] + "." + chan)



Expand Down

0 comments on commit 7dffba4

Please sign in to comment.