HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/beacons/__pycache__/sensehat.cpython-310.pyc
o

�N�g�@sFdZddlZddlZddlZe�e�ZdZdd�Z	dd�Z
dd	�ZdS)
a6
Monitor temperature, humidity and pressure using the SenseHat of a Raspberry Pi
===============================================================================

.. versionadded:: 2017.7.0

:maintainer:    Benedikt Werner <1benediktwerner@gmail.com>
:maturity:      new
:depends:       sense_hat Python module
�NZsensehatcCs&dtvrtSd}t�dt|�d|fS)Nzsensehat.get_pressurez!sensehat.get_pressure is missing.zUnable to load %s beacon: %sF)�__salt__�__virtualname__�log�error)�err_msg�r�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/beacons/sensehat.py�__virtual__s
r	cCs,t|t�sdStjj�|�}d|vrdSdS)z+
    Validate the beacon configuration
    )Fz1Configuration for sensehat beacon must be a list.�sensors)Fz3Configuration for sensehat beacon requires sensors.)TzValid beacon configuration)�
isinstance�list�salt�utils�beacons�list_to_dict)�configrrr�validates
rc	Cs g}dddd�}tjj�|�}|�di�D]x}d|��}|tvr't�d|�q|d|}t|t	�r?t
|d�}t
|d�}n
|�|d�}t
|�}t|t
�rYd	|vrYt�d	d
|�}t|t
�rid	|vrit�d	d
|�}t
|�}t
|�}t|�}||kr�|ks�n|�dd|��||i�q|S)
a�
    Monitor the temperature, humidity and pressure using the SenseHat sensors.

    You can either specify a threshold for each value and only emit a beacon
    if it is exceeded or define a range and emit a beacon when the value is
    out of range.

    Units:
    * humidity:                     percent
    * temperature:                  degrees Celsius
    * temperature_from_pressure:    degrees Celsius
    * pressure:                     Millibars

    .. code-block:: yaml

        beacons:
          sensehat:
            - sensors:
                humidity: 70%
                temperature: [20, 40]
                temperature_from_pressure: 40
                pressure: 1500
    �0z-273.15)ZhumidityZpressureZtemperaturer
z
sensehat.get_z&No sensor for meassuring %s. Skipping.r��%��tagz	sensehat/)r
rrr�getrrrrr�str�re�sub�float�append)	r�retZmin_defaultZsensorZsensor_functionZ
sensor_configZ
sensor_minZ
sensor_maxZ
current_valuerrr�beacon.s2


�r)�__doc__�loggingrZsalt.utils.beaconsr
�	getLogger�__name__rrr	rrrrrr�<module>s