Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/TD22057/insteon-mqtt into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
TD22057 committed Dec 28, 2019
2 parents 47858c6 + c6d3e53 commit 3fd1dd8
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
19 changes: 19 additions & 0 deletions docs/mqtt.md
Original file line number Diff line number Diff line change
Expand Up @@ -1104,4 +1104,23 @@ Sample Configuration:
cool_sp_payload: '{ "temp_f" : {{value}} }'
```

### Polling

If the 'pair' command has been run correctly, the thermostat should push
ambient temp, setpoint temps, humdity, and status message automatically.
However if you want, you can poll the device for the status of these values
as well by running 'get_status'. This command will also get the units (C or F)
specified on the device, which is necessary for properly decoding some of the
temp messages from the device. This command is also run as part of a 'refresh'.
So if you are seeing strange temperatures, try running this command or 'refresh'

Topic:
```
insteon/command/aa.bb.cc
```

Payload:
```
{ "cmd" : "get_status"}
```
---
50 changes: 50 additions & 0 deletions insteon_mqtt/device/Thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,52 @@ def pair(self, on_done=None):
# will chain everything together.
seq.run()

#-----------------------------------------------------------------------
def refresh(self, force=False, on_done=None):
"""Refresh the current device state and database if needed.
This sends a ping to the device. The reply has the current device
state (on/off, level, etc) and the current db delta value which is
checked against the current db value. If the current db is out of
date, it will trigger a download of the database.
This will send out an updated signal for the current device status
whenever possible.
In addition, this also runs the 'get_status' command as well, which
asks the thermostat for the current state of its attributes as well
the current units selected on the device. If you are seeing errors
in temperatures that look like C and F are reversed, running a refresh
may fix the issue.
Args:
force (bool): If true, will force a refresh of the device database
even if the delta value matches as well as a re-query of the
device model information even if it is already known.
on_done: Finished callback. This is called when the command has
completed. Signature is: on_done(success, msg, data)
"""
LOG.info("Device %s cmd: fan status refresh", self.addr)

seq = CommandSeq(self.protocol, "Refresh complete", on_done)

# Send a 0x19 0x03 command to get the fan speed level. This sends a
# refresh ping which will respond w/ the fan level and current
# database delta field. Pass skip_db here - we'll let the dimmer
# refresh handler above take care of getting the database updated.
# Otherwise this handler and the one created in the dimmer refresh
# would download the database twice.
msg = Msg.OutStandard.direct(self.addr, 0x19, 0x03)
msg_handler = handler.DeviceRefresh(self, self.handle_refresh,
force=False, num_retry=3,
skip_db=True)
seq.add_msg(msg, msg_handler)

# If we get the FAN state correctly, then have the dimmer also get
# it's state and update the database if necessary.
seq.add(self.get_status)
seq.run()

#-----------------------------------------------------------------------
def get_status(self, on_done=None):
"""Request the status of the common attributes of the thermostat
Expand All @@ -204,6 +250,10 @@ def get_status(self, on_done=None):
cool setpoint, heat setpoint, and ambient humidity. Will then emit
all necessary signal_* events to cause mqtt messages to be sent
Also receives the units (C or F) selected on the thermostat which is
important for understanding the ambient temp and set point. If you see
odd temperature values, try running 'get_status' or 'refresh'
Args:
on_done: Finished callback. This is called when the command has
completed. Signature is: on_done(success, msg, data)
Expand Down
3 changes: 2 additions & 1 deletion insteon_mqtt/handler/ThermostatCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def msg_received(self, protocol, msg):

# Pull out and process the commands that this handler handles
if msg.cmd1 == STATUS_TEMP:
temp = int(msg.cmd2)
# Temperature is 2x presumably for resolution
temp = int(msg.cmd2) / 2
if self.device.units == self.device.FARENHEIT:
temp = (temp - 32) * 5 / 9
self.device.signal_ambient_temp_change.emit(self.device, temp)
Expand Down

0 comments on commit 3fd1dd8

Please sign in to comment.