Skip to content
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

Add key beeps to switch2477S #37

Open
wants to merge 2 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
16 changes: 3 additions & 13 deletions python/dimmer2477D.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from querier import MsgHandler
from dimmer import Dimmer

from python.mixins.keybeepmixin import KeyBeepMixin

from us.pfrommer.insteon.msg import Msg
from us.pfrommer.insteon.msg import MsgListener
from us.pfrommer.insteon.msg import InsteonAddress
Expand Down Expand Up @@ -60,7 +62,7 @@ def processMsg(self, msg):
return 1


class Dimmer2477D(Dimmer):
class Dimmer2477D(Dimmer, KeyBeepMixin):
"""============== Insteon SwitchLinc Dimmer 2477D ==============="""
def __init__(self, name, addr):
Dimmer.__init__(self, name, addr)
Expand Down Expand Up @@ -165,18 +167,6 @@ def setLEDBLOn(self):
self.querier.setMsgHandler(DefaultMsgHandler("Set LED Backlight ON"))
return self.querier.queryext(0x20, 0x09, [0x00, 0x00, 0x00]);

def setKeyBeepOn(self):
"""setKeyBeepOn()
This sets the dimmer to beep when key is pressed"""
self.querier.setMsgHandler(DefaultMsgHandler("Set Key Beep ON"))
return self.querier.queryext(0x20, 0x0A, [0x00, 0x00, 0x00]);

def setKeyBeepOff(self):
"""setKeyBeepOff()
This sets the dimmer to not beep when key is pressed"""
self.querier.setMsgHandler(DefaultMsgHandler("Set Key Beep OFF"))
return self.querier.queryext(0x20, 0x0B, [0x00, 0x00, 0x00]);

def setRFOff(self):
"""setRFOff()
This sets Rf Off...as an originator, will still hop messages"""
Expand Down
Empty file added python/handlers/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions python/handlers/defaultmessagehandler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
DefaultMsgHandler

This handler provides default message handling by sending message to standard out.
"""

import iofun

from python.querier import MsgHandler

def out(msg = ""):
iofun.out(msg)

class DefaultMsgHandler(MsgHandler):
label = None
def __init__(self, l):
self.label = l
def processMsg(self, msg):
out(self.label + " got msg: " + msg.toString())
return 1
Empty file added python/mixins/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions python/mixins/keybeepmixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
KeyBeepMixin

This mixin provides functionality to control the key beep feature of some devices.
"""

from python.handlers.defaultmessagehandler import DefaultMsgHandler

class KeyBeepMixin:
def setKeyBeepOn(self):
"""setKeyBeepOn()
This sets the dimmer to beep when key is pressed"""
self.querier.setMsgHandler(DefaultMsgHandler("Set Key Beep ON"))
return self.querier.queryext(0x20, 0x0A, [0x00, 0x00, 0x00]);

def setKeyBeepOff(self):
"""setKeyBeepOff()
This sets the dimmer to not beep when key is pressed"""
self.querier.setMsgHandler(DefaultMsgHandler("Set Key Beep OFF"))
return self.querier.queryext(0x20, 0x0B, [0x00, 0x00, 0x00]);
16 changes: 4 additions & 12 deletions python/switch2477S.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,14 @@
from switch import Switch
from linkdb import *

from python.handlers.defaultmessagehandler import DefaultMsgHandler
from python.mixins.keybeepmixin import KeyBeepMixin

from us.pfrommer.insteon.msg import Msg
from us.pfrommer.insteon.msg import MsgListener
from us.pfrommer.insteon.msg import InsteonAddress

def out(msg = ""):
iofun.out(msg)

class DefaultMsgHandler(MsgHandler):
label = None
def __init__(self, l):
self.label = l
def processMsg(self, msg):
out(self.label + " got msg: " + msg.toString())
return 1

class Switch2477S(Switch):
class Switch2477S(Switch, KeyBeepMixin):
"""============== Insteon SwitchLinc 2477S ==============="""
def __init__(self, name, addr):
Switch.__init__(self, name, addr)
Expand Down