@@ -674,7 +674,7 @@ def _publish_setting(self, setting: str) -> None:
674674 )
675675
676676 with JobManager () as jm :
677- jm .upsert_setting (self ._job_id , setting_name , str ( value ) if value is not None else "" )
677+ jm .upsert_setting (self ._job_id , setting_name , value )
678678
679679 def _set_up_exit_protocol (self ) -> None :
680680 # here, we set up how jobs should disconnect and exit.
@@ -796,7 +796,7 @@ def disconnected(self) -> None:
796796 self .logger .debug (e , exc_info = True )
797797
798798 # remove attrs from MQTT
799- self ._clear_mqtt_cache ()
799+ self ._clear_caches ()
800800
801801 self ._log_state (self .state )
802802
@@ -951,7 +951,7 @@ def _confirm_state_in_broker(self, message: pt.MQTTMessage) -> None:
951951 sleep (1 )
952952 self ._publish_setting ("state" )
953953
954- def _clear_mqtt_cache (self ) -> None :
954+ def _clear_caches (self ) -> None :
955955 """
956956 From homie: Devices can remove old properties and nodes by publishing a zero-length payload on the respective topics.
957957 Use "persist" to keep it from clearing.
@@ -962,29 +962,31 @@ def _clear_mqtt_cache(self) -> None:
962962 retain = True ,
963963 )
964964
965- for attr , metadata_on_attr in self .published_settings .items ():
966- if not metadata_on_attr .get ("persist" , False ):
965+ with JobManager () as jm :
966+ for setting , metadata_on_attr in self .published_settings .items ():
967+ if not metadata_on_attr .get ("persist" , False ):
968+ self .publish (
969+ f"pioreactor/{ self .unit } /{ self .experiment } /{ self .job_name } /{ setting } " ,
970+ None ,
971+ retain = True ,
972+ )
973+ jm .upsert_setting (self ._job_id , setting , None )
974+
967975 self .publish (
968- f"pioreactor/{ self .unit } /{ self .experiment } /{ self .job_name } /{ attr } " ,
976+ f"pioreactor/{ self .unit } /{ self .experiment } /{ self .job_name } /{ setting } /$settable" ,
977+ None ,
978+ retain = True ,
979+ )
980+ self .publish (
981+ f"pioreactor/{ self .unit } /{ self .experiment } /{ self .job_name } /{ setting } /$datatype" ,
982+ None ,
983+ retain = True ,
984+ )
985+ self .publish (
986+ f"pioreactor/{ self .unit } /{ self .experiment } /{ self .job_name } /{ setting } /$unit" ,
969987 None ,
970988 retain = True ,
971989 )
972-
973- self .publish (
974- f"pioreactor/{ self .unit } /{ self .experiment } /{ self .job_name } /{ attr } /$settable" ,
975- None ,
976- retain = True ,
977- )
978- self .publish (
979- f"pioreactor/{ self .unit } /{ self .experiment } /{ self .job_name } /{ attr } /$datatype" ,
980- None ,
981- retain = True ,
982- )
983- self .publish (
984- f"pioreactor/{ self .unit } /{ self .experiment } /{ self .job_name } /{ attr } /$unit" ,
985- None ,
986- retain = True ,
987- )
988990
989991 def _check_for_duplicate_activity (self ) -> None :
990992 if is_pio_job_running (self .job_name ) and not is_testing_env ():
0 commit comments