Skip to content

Commit

Permalink
Merge pull request #188 from farmio/master
Browse files Browse the repository at this point in the history
treat DPT 5 (pulse) sensor like every other sensor
  • Loading branch information
Julius2342 committed Mar 2, 2019
2 parents 6e627e8 + 92fbe8f commit 843be9d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
11 changes: 0 additions & 11 deletions xknx/devices/remote_value_dpt_value_1_ucount.py
Expand Up @@ -11,17 +11,6 @@
class RemoteValueDptValue1Ucount(RemoteValue):
"""Abstraction for remote value of KNX DPT 5.010."""

def __init__(self,
xknx,
group_address=None,
device_name=None,
after_update_cb=None):
"""Initialize remote value of KNX DPT 5.010."""
# pylint: disable=too-many-arguments
super(RemoteValueDptValue1Ucount, self).__init__(
xknx, group_address, None,
device_name=device_name, after_update_cb=after_update_cb)

def payload_valid(self, payload):
"""Test if telegram payload may be parsed."""
return (isinstance(payload, DPTArray)
Expand Down
6 changes: 5 additions & 1 deletion xknx/devices/remote_value_sensor.py
Expand Up @@ -11,7 +11,7 @@
DPTElectricCurrent, DPTElectricPotential, DPTEnergy, DPTEnthalpy,
DPTFrequency, DPTHeatFlowRate, DPTHumidity, DPTLux, DPTPartsPerMillion,
DPTPhaseAngleDeg, DPTPhaseAngleRad, DPTPower, DPTPowerFactor, DPTSpeed,
DPTTemperature, DPTUElCurrentmA, DPTVoltage, DPTWsp)
DPTTemperature, DPTUElCurrentmA, DPTValue1Ucount, DPTVoltage, DPTWsp)

from .remote_value import RemoteValue

Expand All @@ -36,12 +36,16 @@ class RemoteValueSensor(RemoteValue):
'heatflowrate': DPTHeatFlowRate,
'phaseanglerad': DPTPhaseAngleRad,
'phaseangledeg': DPTPhaseAngleDeg,
'pulse': DPTValue1Ucount,
'powerfactor': DPTPowerFactor,
'speed': DPTSpeed,
'enthalpy': DPTEnthalpy,
'ppm': DPTPartsPerMillion,

# Generic DPT Without Min/Max and Unit.
'DPT-5': DPTValue1Ucount,
'1byte_unsigned': DPTValue1Ucount,

'DPT-7': DPT2ByteUnsigned,
'2byte_unsigned': DPT2ByteUnsigned,
'DPT-9': DPT2ByteFloat,
Expand Down
7 changes: 0 additions & 7 deletions xknx/devices/sensor.py
Expand Up @@ -7,7 +7,6 @@
* watching for state updates from KNX bus.
"""
from .device import Device
from .remote_value_dpt_value_1_ucount import RemoteValueDptValue1Ucount
from .remote_value_scaling import RemoteValueScaling
from .remote_value_sensor import RemoteValueSensor

Expand All @@ -34,12 +33,6 @@ def __init__(self,
after_update_cb=self.after_update,
range_from=0,
range_to=100)
elif value_type == "pulse":
self.sensor_value = RemoteValueDptValue1Ucount(
xknx,
group_address=group_address,
device_name=self.name,
after_update_cb=self.after_update)
else:
self.sensor_value = RemoteValueSensor(
xknx,
Expand Down
1 change: 1 addition & 0 deletions xknx/knx/dpt_value_1_ucount.py
Expand Up @@ -15,6 +15,7 @@ class DPTValue1Ucount(DPTBase):
value_max = 255
unit = ""
resolution = 1
payload_length = 1

@classmethod
def from_knx(cls, raw):
Expand Down

0 comments on commit 843be9d

Please sign in to comment.