class platypush.backend.sensor.serial.SensorSerialBackend(**kwargs)[source]

Bases: SensorBackend

This backend listens for new events from sensors connected through a serial interface (like Arduino) acting as a wrapper for the serial plugin.



  • plugin (str) – If set, then this plugin instance, referenced by plugin id, will be polled through get_plugin(). Example: 'gpio.sensor.bme280' or 'gpio.sensor.envirophat'.

  • plugin_args (dict) – If plugin is set and its get_measurement() method accepts optional arguments, then you can pass those arguments through plugin_args.

  • thresholds – Thresholds can be either a scalar value or a dictionary (e.g. {"temperature": 20.0}). Sensor threshold events will be fired when measurements get above or below these values. Set it as a scalar if your get_measurement() code returns a scalar, as a dictionary if it returns a dictionary of values. For instance, if your sensor code returns both humidity and temperature in a format like {'humidity':60.0, 'temperature': 25.0}, you’ll want to set up a threshold on temperature with a syntax like {'temperature':20.0} to trigger events when the temperature goes above/below 20 degrees.

  • tolerance (dict or float) –

    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. Example:

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

  • poll_seconds (float) – If set, the thread will wait for the specified number of seconds between a read and the next one.

  • enabled_sensors (dict (in the form name -> [True/False]), set or list) – If get_measurement() returns data in dict form, then enabled_sensors selects which keys should be taken into account when monitoring for new events (e.g. “temperature” or “humidity”).