Skip to content

Commit

Permalink
Sensor support implementation check
Browse files Browse the repository at this point in the history
  • Loading branch information
Magalex2x14 committed Jan 23, 2020
1 parent ddbb603 commit ca19b79
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Supported sensors:
(MiFlora, broadcasts temperature, moisture, illuminance, conductivity, 1 reading per minute, no battery info with firmware v3.2.1)

- HHCCPOT002
(FlowerPot, RoPot, broadcasts moisture and conductivity, 2 readings per minute, no battery info...)
(FlowerPot, RoPot, broadcasts moisture and conductivity, 2 readings per minute, no battery info with firmware v1.2.6)

*The amount of actually received data is highly dependent on the reception conditions (like distance and electromagnetic ambiance), readings numbers are indicated for good RSSI (Received Signal Strength Indicator) of about -75 till -70dBm.*

Expand Down
36 changes: 22 additions & 14 deletions custom_components/mitemp_bt/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,20 +371,28 @@ def discover_ble_devices(config):
if mac in sensors_by_mac:
sensors = sensors_by_mac[mac]
else:
if stype[mac] == "HHCCJCY01":
sensors = [None] * 4
sensors[t_i] = TemperatureSensor(mac)
sensors[m_i] = MoistureSensor(mac)
sensors[c_i] = ConductivitySensor(mac)
sensors[i_i] = IlluminanceSensor(mac)
elif stype[mac] == "HHCCPOT002":
sensors = [None] * 2
sensors[m_i] = MoistureSensor(mac)
sensors[c_i] = ConductivitySensor(mac)
else:
sensors = [None] * 2
sensors[t_i] = TemperatureSensor(mac)
sensors[h_i] = HumiditySensor(mac)
try:
if stype[mac] == "HHCCJCY01":
sensors = [None] * 4
sensors[t_i] = TemperatureSensor(mac)
sensors[m_i] = MoistureSensor(mac)
sensors[c_i] = ConductivitySensor(mac)
sensors[i_i] = IlluminanceSensor(mac)
elif stype[mac] == "HHCCPOT002":
sensors = [None] * 2
sensors[m_i] = MoistureSensor(mac)
sensors[c_i] = ConductivitySensor(mac)
else:
sensors = [None] * 2
sensors[t_i] = TemperatureSensor(mac)
sensors[h_i] = HumiditySensor(mac)
except IndexError as error:
_LOGGER.error(
"Sensor implementation error for %s, %s!",
stype[mac],
mac
)
_LOGGER.error(error)
sensors_by_mac[mac] = sensors
add_entities(sensors)
for sensor in sensors:
Expand Down
2 changes: 1 addition & 1 deletion info.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Supported sensors:
(MiFlora, broadcasts temperature, moisture, illuminance, conductivity, 1 reading per minute, no battery info with firmware v3.2.1)

- HHCCPOT002
(FlowerPot, RoPot, broadcasts moisture and conductivity, 2 readings per minute, no battery info...)
(FlowerPot, RoPot, broadcasts moisture and conductivity, 2 readings per minute, no battery info with firmware v1.2.6)

*The amount of actually received data is highly dependent on the reception conditions (like distance and electromagnetic ambiance), readings numbers are indicated for good RSSI (Received Signal Strength Indicator) of about -75 till -70dBm.*

Expand Down

0 comments on commit ca19b79

Please sign in to comment.