sensor.dht
#
- class platypush.plugins.sensor.dht.SensorDhtPlugin(*_, **__)[source]#
Bases:
SensorPlugin
Plugin to interact with a DHT11/DHT22/AM2302 temperature/humidity sensor through GPIO.
Requires:
Adafruit_Python_DHT
(pip install git+https://github.com/adafruit/Adafruit_Python_DHT.git
)
Triggers:
- __init__(sensor_type: str, pin: int, retries: int = 5, retry_seconds: int = 2, poll_interval: float = 5.0, **kwargs)[source]#
- Parameters:
sensor_type – Type of sensor to be used (supported types: DHT11, DHT22, AM2302).
pin – GPIO PIN where the sensor is connected.
retries – Number of retries in case of failed read (default: 5).
retry_seconds – Number of seconds to wait between retries (default: 2).
- get_measurement(*_, **__) Dict[str, float] [source]#
Get data from the sensor.
- Returns:
A mapping with the measured temperature and humidity. Example:
{ "humidity": 30.0, "temperature": 25.5 }
- read(sensor_type: str | None = None, pin: int | None = None, retries: int | None = None, retry_seconds: int | None = None, **__) Dict[str, float] [source]#
Read data from the sensor.
- Parameters:
sensor_type – Default
sensor_type
override.pin – Default
pin
override.retries – Default
retries
override.retry_seconds – Default
retry_seconds
override.
- Returns:
A mapping with the measured temperature and humidity. Example:
{ "humidity": 30.0, "temperature": 25.5 }
- transform_entities(entities: Dict[str, float | int]) List[Device] [source]#
This method takes a list of entities in any (plugin-specific) format and converts them into a standardized collection of Entity objects. Since this method is called by
publish_entities()
before entity updates are published, you may usually want to extend it to pre-process the entities managed by your extension into the standard format before they are stored and published to all the consumers.