Skip to content

Commit

Permalink
Merge pull request #52 from Danielhiversen/style
Browse files Browse the repository at this point in the history
Style
  • Loading branch information
Danielhiversen authored Apr 19, 2017
2 parents 4e3f4e6 + 5f0b126 commit 8c43694
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 35 deletions.
49 changes: 18 additions & 31 deletions RFXtrx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,21 +361,18 @@ def __init__(self, pkt):
self.pkt = pkt
if isinstance(pkt, lowlevel.RfxMeter):
self.values['Counter value'] = pkt.value
if isinstance(pkt, lowlevel.Temp) \
or isinstance(pkt, lowlevel.TempHumid) \
or isinstance(pkt, lowlevel.TempHumidBaro):
if isinstance(pkt, (lowlevel.Temp, lowlevel.TempHumid,
lowlevel.TempHumidBaro)):
self.values['Temperature'] = pkt.temp
if isinstance(pkt, lowlevel.Bbq):
self.values['Temperature'] = pkt.temp1
self.values['Temperature2'] = pkt.temp2
if isinstance(pkt, lowlevel.Humid) \
or isinstance(pkt, lowlevel.TempHumid) \
or isinstance(pkt, lowlevel.TempHumidBaro):
if isinstance(pkt, (lowlevel.Humid, lowlevel.TempHumid,
lowlevel.TempHumidBaro)):
self.values['Humidity'] = pkt.humidity
self.values['Humidity status'] = pkt.humidity_status_string
self.values['Humidity status numeric'] = pkt.humidity_status
if isinstance(pkt, lowlevel.Baro) \
or isinstance(pkt, lowlevel.TempHumidBaro):
if isinstance(pkt, (lowlevel.Baro, lowlevel.TempHumidBaro)):
self.values['Barometer'] = pkt.baro
self.values['Forecast'] = pkt.forecast_string
self.values['Forecast numeric'] = pkt.forecast
Expand Down Expand Up @@ -416,8 +413,7 @@ def __init__(self, pkt):
self.values['Sound'] = pkt.sound
if isinstance(pkt, lowlevel.Security1):
self.values['Sensor Status'] = pkt.security1_status_string
if not (isinstance(pkt, lowlevel.RfxMeter)
or isinstance(pkt, lowlevel.Energy5)):
if not isinstance(pkt, (lowlevel.Energy5, lowlevel.RfxMeter)):
self.values['Battery numeric'] = pkt.battery
self.values['Rssi numeric'] = pkt.rssi

Expand All @@ -435,12 +431,9 @@ class ControlEvent(RFXtrxEvent):

def __init__(self, pkt):
# pylint: disable=too-many-boolean-expressions
if isinstance(pkt, lowlevel.Lighting1) \
or isinstance(pkt, lowlevel.Lighting2) \
or isinstance(pkt, lowlevel.Lighting3) \
or isinstance(pkt, lowlevel.Lighting4) \
or isinstance(pkt, lowlevel.Lighting5) \
or isinstance(pkt, lowlevel.Lighting6):
if isinstance(pkt, (lowlevel.Lighting1, lowlevel.Lighting2,
lowlevel.Lighting3, lowlevel.Lighting4,
lowlevel.Lighting5, lowlevel.Lighting6)):
device = LightingDevice(pkt)
elif isinstance(pkt, lowlevel.RollerTrol):
device = RollerTrolDevice(pkt)
Expand Down Expand Up @@ -480,10 +473,6 @@ def __str__(self):

class StatusEvent(RFXtrxEvent):
""" Concrete class for status """

def __init__(self, pkt):
super(StatusEvent, self).__init__(pkt)

def __str__(self):
return "{0} device=[{1}]".format(
type(self), self.device)
Expand Down Expand Up @@ -597,22 +586,20 @@ def receive_blocking(self):
data = self.serial.read()
except TypeError:
continue
if len(data) > 0:
if data == '\x00':
continue
pkt = bytearray(data)
data = self.serial.read(pkt[0])
pkt.extend(bytearray(data))
if self.debug:
print("Recv: " + " ".join("0x{0:02x}".format(x)
for x in pkt))
return self.parse(pkt)
if not data or data == '\x00':
continue
pkt = bytearray(data)
data = self.serial.read(pkt[0])
pkt.extend(bytearray(data))
if self.debug:
print("Recv: " + " ".join("0x{0:02x}".format(x) for x in pkt))
return self.parse(pkt)

def send(self, data):
""" Send the given packet """
if isinstance(data, bytearray):
pkt = data
elif isinstance(data, str) or isinstance(data, bytes):
elif isinstance(data, (bytes, str)):
pkt = bytearray(data)
else:
raise ValueError("Invalid type")
Expand Down
4 changes: 0 additions & 4 deletions RFXtrx/lowlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,10 +1051,6 @@ class SensorPacket(Packet):
Mapping of forecast types to string
"""

def __init__(self):
"""Constructor"""
super(SensorPacket, self).__init__()


###############################################################################
# Temp class
Expand Down

0 comments on commit 8c43694

Please sign in to comment.