SORRY! Fix for broken motion/door state!

This commit is contained in:
raspberry
2018-02-21 19:55:47 +03:00
parent 6f8bbe1599
commit ed116b431b
4 changed files with 22 additions and 7 deletions
+1 -1
View File
@@ -1 +1 @@
1.0.2 1.0.3
+11
View File
@@ -0,0 +1,11 @@
#SHELL := /bin/bash
ARGS = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
commit:
git add .
git commit -m "$(call ARGS,\"updating to lastest local code\")"
git push
%:
@:
+3 -1
View File
@@ -1,5 +1,7 @@
aqara: aqara:
image: monster1025/aqara-mqtt:1-armhf #image: monster1025/aqara-mqtt:1-armhf
build: .
dockerfile: Dockerfile-armhf
container_name: aqara container_name: aqara
volumes: volumes:
- "./config:/app/config" - "./config:/app/config"
+7 -5
View File
@@ -74,6 +74,7 @@ class Mqtt:
model = sidprops.get("model",model) model = sidprops.get("model",model)
sid = sidprops.get("name",sid) sid = sidprops.get("name",sid)
items = {}
for key, value in data.items(): for key, value in data.items():
# fix for latest motion value # fix for latest motion value
if (model == "motion" and key == "no_motion"): if (model == "motion" and key == "no_motion"):
@@ -88,23 +89,24 @@ class Mqtt:
# fix for rgb format # fix for rgb format
if (key == "rgb" and self._is_int(value)): if (key == "rgb" and self._is_int(value)):
value = self._color_xiaomi_to_rgb(value) value = self._color_xiaomi_to_rgb(value)
items[key] = value
if self.json == True: if self.json == True:
PATH_FMT = self.prefix + "/{model}/{sid}/json" PATH_FMT = self.prefix + "/{model}/{sid}/json"
topic = PATH_FMT.format(model=model, sid=sid) topic = PATH_FMT.format(model=model, sid=sid)
values = {} values = {}
values['sid'] = sid values['sid'] = sid
for key, value in data.items(): for key in items:
values[key] = value values[key] = items[key]
jsondata = json.dumps(values) jsondata = json.dumps(values)
_LOGGER.info("Publishing message to topic " + topic + ": " + str(jsondata) + ".") _LOGGER.info("Publishing message to topic " + topic + ": " + str(jsondata) + ".")
self._client.publish(topic, payload=jsondata, qos=0, retain=retain) self._client.publish(topic, payload=jsondata, qos=0, retain=retain)
else: else:
for key, value in data.items(): for key in items:
PATH_FMT = self.prefix + "/{model}/{sid}/{prop}" PATH_FMT = self.prefix + "/{model}/{sid}/{prop}"
topic = PATH_FMT.format(model=model, sid=sid, prop=key) topic = PATH_FMT.format(model=model, sid=sid, prop=key)
_LOGGER.info("Publishing message to topic " + topic + ": " + str(value) + ".") _LOGGER.info("Publishing message to topic " + topic + ": " + str(items[key]) + ".")
self._client.publish(topic, payload=value, qos=0, retain=retain) self._client.publish(topic, payload=items[key], qos=0, retain=retain)
def _mqtt_on_connect(self, client, userdata, rc, unk): def _mqtt_on_connect(self, client, userdata, rc, unk):
_LOGGER.info("Connected to mqtt server.") _LOGGER.info("Connected to mqtt server.")