Unable to update from sensor: could not convert string to float: 'unknown' - Issue with hygrostat

I have a generic hygrostat:

generic_hygrostat:
  - name: "Bagno ospiti"
    humidifier: light.relay_2_40f5202a76ec
    target_sensor: sensor.0x00158d000678e795_humidity
    device_class: "dehumidifier"
    target_humidity: 65
    dry_tolerance: 1

Target sensor is a mqtt sensor.

At the reboot of homeassistant I get in log that advice:

Source: components/generic_hygrostat/humidifier.py:354
Integration: Generic hygrostat (documentation, issues)
First occurred: 08:11:12 (3 occurrences)
Last logged: 08:11:48

Unable to update from sensor: could not convert string to float: 'unknown'

And in effect hygrostat card is missing also target humidity:

Screenshot from 2022-05-19 08-24-21

If I move the blu circle target humidity, I can re-read target hum.

Screenshot from 2022-05-19 08-25-03

I know the issue is a slow update from MQTT, but, how can I prevent it?

Thank you!

Set the retained flag on whatever is sending the mqtt message.

That way the last state is stored in the broker and when home assistant starts it subscribes to the topic and receives the last message stored in the broker.

Is it possible to set, via config a default value (.e.g “20”) instead of an unknown?

I use zigbee2mqtt but I would not use retain (I have also actuactor… I don’t want that they retain their settings, e.g. last clicked button…)

Yeah you definitely don’t want commands being retained, only states.

You can do this on a per device setting in zigbee2mqtt. Is your sensor a separate device?

In the zigbee2mqtt interface, click on a device. It’s one of the top settings in the settings tab for the device.

Added.
It has retained (restarted HASS and got previos values instead of “unknown” on view card) but… hygrostat got same issue:

Logger: homeassistant.components.generic_hygrostat.humidifier
Source: components/generic_hygrostat/humidifier.py:354
Integration: Generic hygrostat (documentation, issues)
First occurred: 08:39:17 (2 occurrences)
Last logged: 08:39:17

Unable to update from sensor: could not convert string to float: 'unknown'