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 Visitor sensor class #78

Open
wants to merge 1 commit 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
18 changes: 18 additions & 0 deletions pychonet/VisitorSensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from pychonet.EchonetInstance import EchonetInstance
from pychonet.lib.epc_functions import _int, DICT_31_8_LEVELS, DICT_41_ON_OFF


class VisitorSensor(EchonetInstance):
EPC_FUNCTIONS = {
# Visitor sensor class
0xB0: [_int, DICT_31_8_LEVELS], # "Detection threshold level",
0xB1: [_int, DICT_41_ON_OFF], # "Visitor detection status",
0xBE: _int, # "Visitor detection holding time",
}

def __init__(self, host, api_connector, instance=0x1):
self._eojgc = 0x00
self._eojcc = 0x08
EchonetInstance.__init__(
self, host, self._eojgc, self._eojcc, instance, api_connector
)
11 changes: 11 additions & 0 deletions pychonet/lib/epc_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@
0x38: "level-8",
}

DICT_31_8_LEVELS = {
0x31: "level-1",
0x32: "level-2",
0x33: "level-3",
0x34: "level-4",
0x35: "level-5",
0x36: "level-6",
0x37: "level-7",
0x38: "level-8",
}


def _swap_dict(d: dict):
return {v: k for k, v in d.items()}
Expand Down
Loading