Skip to content

WIP Create superclass for insteon thermostats #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2016 David McNett

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 26 additions & 2 deletions insteonplm/devices/climateControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
_LOGGER = logging.getLogger(__name__)


class ClimateControl_2441th(Device):
"""Thermostat model 2441TH."""
class ClimateControl_Base(Device):
"""Thermostat model."""

def __init__(self, plm, address, cat, subcat, product_key=None,
description=None, model=None):
"""Init the DimmableLightingControl Class."""
Device.__init__(self, plm, address, cat, subcat, product_key,
description, model)

_LOGGER.debug("Created instance of Insteon Climate Controller")

self._stateList[0x01] = CoolSetPoint(
self._address, "coolSetPoint", 0x01, self._send_msg,
self._message_callbacks, 0x00)
Expand Down Expand Up @@ -100,3 +102,25 @@ def async_refresh_state(self):
# pylint: disable=unused-argument
def _mode_changed(self, addr, group, val):
self.async_refresh_state()


class ClimateControl_2441th(ClimateControl_Base):
"""TH2441TH thermostat model."""

def __init__(self, plm, address, cat, subcat, product_key=None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need init if all it does is call super().init

description=None, model=None):
"""Constructor, delegates most work to the base thermostat class."""
_LOGGER.debug("Created instance of 2441TH controller")
ClimateControl_Base.__init__(self, plm, address, cat, subcat,
product_key, description, model)


class ClimateControl_2441v(ClimateControl_Base):
"""TH2441V thermostat adapter model."""

def __init__(self, plm, address, cat, subcat, product_key=None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need init if all it does is call super.init()

description=None, model=None):
"""Constructor, delegates most work to the base thermostat class."""
_LOGGER.debug("Created instance of 2441V controller")
ClimateControl_Base.__init__(self, plm, address, cat, subcat,
product_key, description, model)
4 changes: 2 additions & 2 deletions insteonplm/devices/ipdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
SwitchedLightingControl_2334_222_6,
SwitchedLightingControl_2334_222_8,
SwitchedLightingControl_2663_222)
from insteonplm.devices.climateControl import ClimateControl_2441th
from insteonplm.devices.climateControl import (ClimateControl_2441th, ClimateControl_2441v)
from insteonplm.devices.securityHealthSafety import (SecurityHealthSafety,
SecurityHealthSafety_2421,
SecurityHealthSafety_2842_222,
Expand Down Expand Up @@ -248,7 +248,7 @@ class IPDB():
Product(0x05, 0x00, None, 'Broan SMSC080 Exhaust Fan', '', None),
Product(0x05, 0x01, 0x000002, 'EZTherm', '', None),
Product(0x05, 0x02, None, 'Broan SMSC110 Exhaust Fan', '', None),
Product(0x05, 0x03, 0x00001F, 'Thermostat Adapter', '2441V', None),
Product(0x05, 0x03, None, 'Thermostat Adapter', '2441V', ClimateControl_2441v),
Product(0x05, 0x04, 0x000024, 'EZTherm', '', None),
Product(0x05, 0x05, 0x000038, 'Broan, Venmar, BEST Rangehoods', '', None),
Product(0x05, 0x07, None, 'Wireless Thermostat', '2441ZTH', ClimateControl_2441th),
Expand Down
3 changes: 2 additions & 1 deletion insteonplm/plm.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,8 @@ def _get_device_info(self):
self.devices.add_device_callback(self._new_device_added)

for addr in self._aldb_devices:
_LOGGER.debug('Getting device info for %s', Address(addr).human)
_LOGGER.debug('Queueing send request for device info for %s',
Address(addr).human)
self._aldb_devices[addr].id_request()

_LOGGER.debug('Ending _get_device_info')
Expand Down
26 changes: 20 additions & 6 deletions insteonplm/states/thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,24 @@ def __init__(self, address, statename, group, send_message_method,
send_message_method,
message_callbacks, defaultvalue)

self._update_method = self._send_status_request
self._updatemethod = self._send_status_request

self._register_messages()

def _send_status_request(self):
_LOGGER.debug("Sending status request")
msg = StandardSend(
address=self._address,
commandtuple=COMMAND_THERMOSTAT_GET_ZONE_INFORMATION_0X6A_NONE,
cmd2=0x00)
self._send_method(msg, self._status_received)

def _status_received(self, msg):
_LOGGER.debug("Received temperature status update")
self._update_subscribers(msg.cmd2 / 2)

def _temp_received(self, msg):
_LOGGER.debug("Received temperature value update")
self._update_subscribers(msg.cmd2 / 2)

def _register_messages(self):
Expand Down Expand Up @@ -90,7 +93,7 @@ def __init__(self, address, statename, group, send_message_method,
address, statename, group, send_message_method,
message_callbacks, defaultvalue)

self._update_method = self._send_status_request
self._updatemethod = self._send_status_request

self._register_messages()

Expand All @@ -102,9 +105,11 @@ def _send_status_request(self):
self._send_method(msg, self._status_received)

def _status_received(self, msg):
_LOGGER.debug("Received humidity status")
self._update_subscribers(msg.cmd2)

def _humidity_received(self, msg):
_LOGGER.debug("Received humidity value")
self._update_subscribers(msg.cmd2)

def _register_messages(self):
Expand Down Expand Up @@ -136,7 +141,7 @@ def __init__(self, address, statename, group, send_message_method,
address, statename, group, send_message_method, message_callbacks,
defaultvalue)

self._update_method = self._send_status_request
self._updatemethod = self._send_status_request

self._register_messages()

Expand Down Expand Up @@ -188,9 +193,11 @@ def _send_status_request(self):
self._send_method(msg, self._status_received)

def _status_received(self, msg):
_LOGGER.info("mode standard status received")
self._update_subscribers(ThermostatMode(msg.cmd2))

def _ext_status_received(self, msg):
_LOGGER.info("mode extended status received")
sysmode = msg.userdata['d6']
ext_mode = sysmode >> 4
if ext_mode == 0:
Expand Down Expand Up @@ -253,7 +260,7 @@ def __init__(self, address, statename, group, send_message_method,
address, statename, group, send_message_method, message_callbacks,
defaultvalue)

self._update_method = self._send_status_request
self._updatemethod = self._send_status_request

self._register_messages()

Expand Down Expand Up @@ -300,9 +307,11 @@ def _send_status_request(self):
self._send_method(msg, self._status_received)

def _status_received(self, msg):
_LOGGER.debug("Fan standard status message received")
self._update_subscribers(ThermostatMode(msg.cmd2))

def _ext_status_received(self, msg):
_LOGGER.debug("Fan extended status message received")
sysmode = msg.userdata['d6']
ext_mode = sysmode & 0x0f
if ext_mode == 0:
Expand Down Expand Up @@ -356,7 +365,7 @@ def __init__(self, address, statename, group, send_message_method,
address, statename, group, send_message_method, message_callbacks,
defaultvalue)

self._update_method = self._send_status_request
self._updatemethod = self._send_status_request

self._register_messages()

Expand All @@ -371,6 +380,7 @@ def set(self, val):
self._send_method(msg, self._set_cool_point_ack)

def _set_cool_point_ack(self, msg):
_LOGGER.debug("Cooling setpoint standard received")
self._update_subscribers(msg.cmd2 / 2)

def _send_status_request(self):
Expand All @@ -381,6 +391,7 @@ def _send_status_request(self):
self._send_method(msg, self._status_message_received)

def _status_message_received(self, msg):
_LOGGER.debug("Cooling standard status received")
self._update_subscribers(msg.cmd2 / 2)

def _register_messages(self):
Expand All @@ -398,6 +409,7 @@ def _register_messages(self):
self._ext_status_received)

def _ext_status_received(self, msg):
_LOGGER.debug("Cooling extended status received")
cool_sp = msg.userdata['d7'] / 2
self._update_subscribers(cool_sp)

Expand All @@ -412,7 +424,7 @@ def __init__(self, address, statename, group, send_message_method,
address, statename, group, send_message_method, message_callbacks,
defaultvalue)

self._update_method = self._send_status_request
self._updatemethod = self._send_status_request

self._register_messages()

Expand All @@ -437,6 +449,7 @@ def _send_status_request(self):
self._send_method(msg, self._status_message_received)

def _status_message_received(self, msg):
_LOGGER.debug("Heating standard status received")
self._update_subscribers(msg.cmd2 / 2)

def _register_messages(self):
Expand All @@ -457,5 +470,6 @@ def _register_messages(self):
self._ext_status_received)

def _ext_status_received(self, msg):
_LOGGER.debug("Heating extended status received")
heat_sp = msg.userdata['d12'] / 2
self._update_subscribers(heat_sp)