Esempio n. 1
0
 async def send_error_to_server(self, error: str) -> None:
     while not shared_flags.wifi_is_connected and not shared_flags.mqtt_is_connected:
         await asyncio.sleep(0)
     error_dict = config.unit_id_dict.copy()
     error_dict.update({"error": error})
     error_json = ujson.dumps(error_dict)
     message = MqttMessage(config.mqtt_topic_error, error_json)
     await self.mqtt_service.add_outgoing_message_to_queue(message)
     print(error)
Esempio n. 2
0
 async def send_status_to_server(self) -> None:
     while not shared_flags.wifi_is_connected and not shared_flags.mqtt_is_connected:
         await asyncio.sleep(0)
     status_dict = config.unit_id_dict.copy()
     status_dict.update([
         await self.soil_moisture_sensor.read_percent(300), await
         self.light_sensor.read_percent(300),
         self.growlight_relay.get_state()
     ])
     status_json = ujson.dumps(status_dict)
     message = MqttMessage(config.mqtt_topic_status, status_json)
     await self.mqtt_service.add_outgoing_message_to_queue(message)
Esempio n. 3
0
 async def send_status_to_server(self) -> None:
     while not shared_flags.wifi_is_connected and not shared_flags.mqtt_is_connected:
         await asyncio.sleep(0)
     status_dict = config.unit_id_dict.copy()
     status_dict.update({
         'modules': [
             await self.water_temp_sensor.get_first_reading_in_celsius(),
             await self.growlight_relay.get_state()
         ]
     })
     status_json = ujson.dumps(status_dict)
     message = MqttMessage(config.mqtt_topic_status, status_json)
     await self.mqtt_service.add_outgoing_message_to_queue(message)
Esempio n. 4
0
 async def send_status_to_server(self) -> None:
     while not shared_flags.wifi_is_connected and not shared_flags.mqtt_is_connected:
         await asyncio.sleep(0)
     status_dict = config.unit_id_dict.copy()
     status_dict.update([
         ################################################
         # TODO: Retrieve data from hardware modules
         #       to be included in the status update.
         ################################################
     ])
     status_json = ujson.dumps(status_dict)
     message = MqttMessage(config.mqtt_topic_status, status_json)
     await self.mqtt_service.add_outgoing_message_to_queue(message)
Esempio n. 5
0
 async def send_status_to_server(self) -> None:
     while not shared_flags.wifi_is_connected and not shared_flags.mqtt_is_connected:
         await asyncio.sleep(0)
     status_dict = config.unit_id_dict.copy()
     status_dict.update([
         await self.water_temp_sensor.read_first_celsius(),
         self.growlight_relay.get_state(),
         self.irrigation_relay.get_state(),
         ("irrigationOnSec", config.irrigation_on_sec),
         ("irrigationOffSec", config.irrigation_off_sec)
     ])
     status_json = ujson.dumps(status_dict)
     message = MqttMessage(config.mqtt_topic_status, status_json)
     await self.mqtt_service.add_outgoing_message_to_queue(message)