ESP32 MQTT IoT Communication
Loading...
Searching...
No Matches
device_writer.SensorWriter Class Reference

Class represensting a Sensor Object. More...

Inheritance diagram for device_writer.SensorWriter:
Collaboration diagram for device_writer.SensorWriter:

Public Member Functions

None __init__ (self, str sensor_address, DeviceWriter device, str sensor_name, str sensor_description, str unit)
 Constructor for the Sensor.
 
str address (self)
 
str sql_query (self)
 Returns The Object encoded into an "INSERT" SQL statement.
 
ReadingsWriter create_readings (self, float data_value)
 Creates a readings object.
 
- Public Member Functions inherited from device_writer.Writer
str __str__ (self)
 Returns an SQL insert query as a str.
 
None insert (self, sqlite3.Connection db_connection)
 Inserts the object into the provided database.
 

Protected Attributes

 _sensor_address
 Address of the sensor connected to a device.
 
 _device
 Device object that the sensor is connected to.
 
 _sensor_name
 Sensor name to identify object.
 
 _sensor_description
 Brief description of sensor.
 
 _unit
 Unit of readings.
 

Detailed Description

Class represensting a Sensor Object.

Used to update the database as well as creating readings objects that keeps track of the MAC Address of the device the sensor is attached to aswell as the individual Sensor Address.

Class represensting a Sensor Object used to update the DB and to create readings objects

Constructor & Destructor Documentation

◆ __init__()

None device_writer.SensorWriter.__init__ (   self,
str  sensor_address,
DeviceWriter  device,
str  sensor_name,
str  sensor_description,
str  unit 
)

Constructor for the Sensor.

Parameters
sensor_addressAddress of the sensor connected to a device
deviceDevice object that the sensor is connected to
sensor_nameSensor name to identify object
sensor_descriptionBrief description of sensor
unitUnit of readings
Constructor for the Sensor

Member Function Documentation

◆ create_readings()

ReadingsWriter device_writer.SensorWriter.create_readings (   self,
float  data_value 
)

Creates a readings object.

Parameters
data_valueData value recieved
typedata_value float
Returns
Returns readings Object
Creates a readings object

:param data_value: Data value recieved
:type data_value: float
@return Returns 

◆ sql_query()

str device_writer.SensorWriter.sql_query (   self)

Returns The Object encoded into an "INSERT" SQL statement.

Returns
INSERT Statement
Returns The Object encoded into an "INSERT" SQL statement

Reimplemented from device_writer.Writer.


The documentation for this class was generated from the following file: