Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #181 from koying/remote_tweaks
Browse files Browse the repository at this point in the history
FIX: last_button_event attr + force update
  • Loading branch information
robmarkcole authored Jan 29, 2020
2 parents 0837e82 + 21eacd0 commit 7cbb35c
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions custom_components/huesensor/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
}
DEVICE_CLASSES = {"SML": "motion"}
ATTRS = {
"RWL": ["last_updated", "battery", "on", "reachable"],
"ROM": ["last_updated", "battery", "on", "reachable"],
"ZGP": ["last_updated"],
"FOH": ["last_updated"],
"RWL": ["last_updated", "last_button_event", "battery", "on", "reachable"],
"ROM": ["last_updated", "last_button_event", "battery", "on", "reachable"],
"ZGP": ["last_updated", "last_button_event"],
"FOH": ["last_updated", "last_button_event"],
"Z3-": [
"last_updated",
"last_button_event",
"battery",
"on",
"reachable",
Expand Down Expand Up @@ -107,6 +108,7 @@ def parse_zgp(response):
"model": "ZGP",
"name": response["name"],
"state": button,
"last_button_event": button,
"last_updated": response["state"]["lastupdated"].split("T"),
}
return data
Expand All @@ -133,6 +135,7 @@ def parse_rwl(response):
"battery": response["config"]["battery"],
"on": response["config"]["on"],
"reachable": response["config"]["reachable"],
"last_button_event": button,
"last_updated": response["state"]["lastupdated"].split("T"),
}
return data
Expand Down Expand Up @@ -165,6 +168,7 @@ def parse_foh(response):
"model": "FOH",
"name": response["name"],
"state": button,
"last_button_event": button,
"last_updated": response["state"]["lastupdated"].split("T"),
}
return data
Expand All @@ -191,6 +195,7 @@ def parse_z3_rotary(response):
"battery": response["config"]["battery"],
"on": response["config"]["on"],
"reachable": response["config"]["reachable"],
"last_button_event": button,
"last_updated": response["state"]["lastupdated"].split("T"),
}
return data
Expand All @@ -212,7 +217,10 @@ def parse_z3_switch(response):
else:
button = Z3_BUTTON[press]

data = {"state": button}
data = {
"last_button_event": button,
"state": button
}
return data


Expand Down Expand Up @@ -371,6 +379,11 @@ def device_state_attributes(self):
if data:
return {key: data.get(key) for key in ATTRS.get(data["model"], [])}

@property
def force_update(self):
"""Force update."""
return True

def turn_on(self, **kwargs):
"""Do nothing."""

Expand Down

0 comments on commit 7cbb35c

Please sign in to comment.