sensor.ltr559#

class platypush.plugins.sensor.ltr559.SensorLtr559Plugin(*_, **__)[source]#

Bases: SensorPlugin

Plugin to interact with an LTR559 light and proximity sensor

Requires:

  • ltr559 (pip install ltr559)

  • smbus (pip install smbus)

Triggers:

__init__(**kwargs)[source]#
Parameters:
  • thresholds

    A number, numeric pair or mapping of str to number/numeric pair representing the thresholds for the sensor.

    Examples:

    # Any value below 25 from any sensor will trigger a
    # SensorDataBelowThresholdEvent, if the previous value was
    # equal or above, and any value above 25 will trigger a
    # SensorDataAboveThresholdEvent, if the previous value was
    # equal or below
    thresholds: 25.0
    
    # Same as above, but the threshold is only applied to
    # ``temperature`` readings
    thresholds:
        temperature: 25.0
    
    # Any value below 20 from any sensor will trigger a
    # SensorDataBelowThresholdEvent, if the previous value was
    # equal or above, and any value above 25 will trigger a
    # SensorDataAboveThresholdEvent, if the previous value was
    # equal or below (hysteresis configuration with double
    # threshold)
    thresholds:
        - 20.0
        - 25.0
    
    # Same as above, but the threshold is only applied to
    # ``temperature`` readings
    thresholds:
        temperature:
            - 20.0
            - 25.0
    

  • tolerance

    If set, then the sensor change events will be triggered only if the difference between the new value and the previous value is higher than the specified tolerance. For example, if the sensor data is mapped to a dictionary:

    {
        "temperature": 0.01,  # Tolerance on the 2nd decimal digit
        "humidity": 0.1       # Tolerance on the 1st decimal digit
    }
    

    Or, if it’s a raw scalar number:

    0.1  # Tolerance on the 1st decimal digit
    

    Or, if it’s a list of values:

    [
        0.01,   # Tolerance on the 2nd decimal digit for the first value
        0.1     # Tolerance on the 1st decimal digit for the second value
    ]
    

  • enabled_sensors – If get_measurement() returns a key-value mapping, and enabled_sensors is set, then only the reported sensor keys will be returned.

get_measurement(*_, **__)[source]#
Returns:

dict. Example:

output = {
    "light": 109.3543,     # Lux
    "proximity": 103       # The higher the value, the nearest the object, within a ~5cm range
}

transform_entities(entities: Dict[str, int | float]) 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.