Skip to content

Commit 21888b9

Browse files
authored
Merge pull request #86 from raetha/devel
Various updates for v3.1
2 parents 720a46e + b1d9be0 commit 21888b9

File tree

4 files changed

+463
-210
lines changed

4 files changed

+463
-210
lines changed

readme.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,21 +226,21 @@ Once run it will present a menu of its functions:
226226
Home Assistant simply needs to be configured with the MQTT broker that the gateway publishes topics to. Once configured, the MQTT integration will automatically add devices for each sensor along with entites for the state, battery_level, and signal_strength. By default these entities will have a device_class of "opening" for contact sensors, "motion" for motion sensors, and "moisture" for leak sensors. They will be named for the sensor type and MAC, e.g. Wyze Sense Contact Sensor AABBCCDD. To adjust the device_class to "door" or "window", and set a custom name, update the sensors.yaml configuration file and replace the defaults, then restart WyzeSense2MQTT. For a comprehensive list of device classes that Home Assistant recognizes, see the [binary_sensor documentation](https://www.home-assistant.io/integrations/binary_sensor/).
227227

228228
## Compatible Hardware
229-
### Bridge Devices
229+
### Wyze Branded
230230
* Wyze Sense Bridge (WHSB1)
231-
* Neos Smart Bridge (N-LSP-US1) - Untested, but theoretically compatible
232-
233-
### Sensors
234231
* Wyze Sense Bridge Sensors
235232
* Contact Sensor v1
236233
* Motion Sensor v1
237-
* Neos Smart Sensors - Untested, but theoretically compatible
238-
* Contact Sensor
239-
* Leak Sensor
240-
* Motion Sensor
241-
* Wyze Sense Hub Sensors - Requires installing the Wyze Sense Hub firmware onto a Wyze Sense Bridge (unsupported and untested)
234+
* Wyze Sense Hub Sensors - Requires installing the Wyze Sense Hub firmware onto a Wyze Sense Bridge (unsupported)
242235
* Entry Sensor v2 (WSES2)
243236
* Motion Sensor v2 (WSMS2)
244-
* Climate Sensor (WSCS1) - Coming Soon Hopefully
245-
* Keypad (WSKP1) - Coming Soon Hopefully
246-
* Leak Sensor (WSLS1) - Coming Soon Hopefully
237+
* Climate Sensor (WSCS1)
238+
* Leak Sensor (WSLS1)
239+
* Keypad (WSKP1) - Future Possibility (need help)
240+
241+
### Neos Smart Branded
242+
* Neos Smart Bridge (N-LSP-US1)
243+
* Neos Smart Sensors - Not tested, but theoretically compatible
244+
* Contact Sensor
245+
* Motion Sensor
246+
* Leak Sensor

wyzesense2mqtt/bridge_tool_cli.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,12 @@
2626
import logging
2727
import binascii
2828
import wyzesense
29-
29+
from datetime import datetime
3030

3131
def on_event(ws, e):
32-
s = f"[{e.Timestamp.strftime('%Y-%m-%d %H:%M:%S')}][{e.MAC}]"
33-
if e.Type == 'state':
34-
(s_type, s_state, s_battery, s_signal) = e.Data
35-
s += f"StateEvent: sensor_type={s_type}, state={s_state}, " \
36-
f"battery={s_battery}, signal={s_signal}"
37-
else:
38-
s += f"RawEvent: type={e.Type}, data={e.Data}"
32+
s = f"[{datetime.fromtimestamp(e.timestamp).strftime('%Y-%m-%d %H:%M:%S')}][{e.mac}]: {e}"
3933
print(s)
4034

41-
4235
def main(args):
4336
if args['--debug']:
4437
loglevel = logging.DEBUG - (1 if args['--verbose'] else 0)
@@ -109,13 +102,34 @@ def Fix(unused_args):
109102
print("Bad sensors removed")
110103
logging.debug("Bad sensors removed")
111104

105+
def Chime(args):
106+
if len(args) < 4:
107+
print("Need 4 parameters")
108+
return
109+
110+
mac, ring, repeat, volume = args
111+
ws.PlayChime(mac, int(ring), int(repeat), int(volume))
112+
113+
def Raw(args):
114+
if len(args) <= 0:
115+
print("Missing argument!")
116+
return
117+
118+
data = args[0]
119+
data = bytes([int(x, 16) for x in data.strip().split(',')])
120+
str_data = ','.join([f"{x:02X}" for x in data])
121+
print(f"Sending raw bytes: {str_data}")
122+
ws.SendRaw(data)
123+
112124
def HandleCmd():
113125
cmd_handlers = {
114-
'L': ('L - List paired sensors', List),
115-
'P': ('P - Pair new sensors', Pair),
116-
'U': ('U <mac> - Unpair sensor', Unpair),
117-
'F': ('F - Fix invalid sensors', Fix),
118-
'X': ('X - Exit tool', None),
126+
'L': ('L - [L]ist paired sensors', List),
127+
'P': ('P - [P]air new sensors', Pair),
128+
'U': ('U - [U]npair sensor, args: <mac>', Unpair),
129+
'F': ('F - [F]ix invalid sensors', Fix),
130+
'C': ('C - Play [C]hime, args: <mac> <ring> <repeat> <volume>', Chime),
131+
'R': ('R - Sending [R]aw packet, args: <hex bytes, separated by comma', Raw),
132+
'X': ('X - E[X]it tool', None),
119133
}
120134

121135
for v in list(cmd_handlers.values()):

0 commit comments

Comments
 (0)