The other possibility is that the field/type in the packet generated by 
MQTTSubscribe is not phenomenon. From the config, it looks like it should 
be. If you set debug = 1, we can see what MQTTSubscribe is putting in the 
packet.
For what's worth, I got a small testcase working and see string data in 
both the loop and archive.
-rich
On Monday, 8 February 2021 at 10:46:36 UTC-5 [email protected] wrote:

> The error you are getting is coming from the ScalarStats accumulator, not 
> the FirstLast accumulator. For some reason, the latter is not getting 
> used, despite your configuration information (which looks correct).
>
> Is there another type besides phenomenon which has a string in it?
>
> -tk
>
> On Mon, Feb 8, 2021 at 1:46 AM Tarmo <[email protected]> wrote:
>
>> Thank you!
>>
>> It seems that the attempt to convert string to float still happens. I 
>> will attach snippets from log and config here. The field name which is 
>> causing trouble is "phenomenon".
>>
>> [MQTTSubscribeDriver]
>>     # This section is for the MQTTSubscribe driver.
>>
>>     # The driver to use:
>>     driver = user.MQTTSubscribe
>>
>>     # The MQTT server.
>>     # Default is localhost.
>>     host = localhost
>>
>>     # The port to connect to.
>>     # Default is 1883.
>>     port = 1883
>>
>>     # Maximum period in seconds allowed between communications with the 
>> broker.
>>     # Default is 60.
>>     keepalive = 60
>>
>>     # username for broker authentication.
>>     # Default is None.
>>     username = rtl
>>
>>     # password for broker authentication.
>>     # Default is None.
>>     password = xx
>>
>>     # Configuration for the message callback.
>>     [[message_callback]]
>>         type = individual
>>
>>     # The topics to subscribe to.
>>     [[topics]]
>>         unit_system = METRIC
>>         use_topic_as_fieldname = true
>>         use_server_datetime = true
>>
>>         [[[rtl_433/lab/devices/Solight-TE44/1/4/temperature_C]]]
>>             name = outTemp
>>         [[[emhi/26038/uvindex]]]
>>             name = UV
>>         [[[emhi/26038/airpressure]]]
>>             name = pressure
>>         [[[emhi/26038/precipitations]]]
>>             name = rain
>>             contains_total = true
>>         [[[emhi/26038/relativehumidity]]]
>>             name = outHumidity
>>         [[[emhi/26038/winddirection]]]
>>             name = windDir
>>         [[[emhi/26038/windspeed]]]
>>             name = windSpeed
>>             units = meter_per_second
>>         [[[emhi/26038/windspeedmax]]]
>>             name = windGust
>>             units = meter_per_second
>>         [[[emhi/26038/phenomenon]]]
>>             conversion_type = None
>>
>> [Accumulator]
>>     [[phenomenon]]
>>         accumulator = firstlast
>>         extractor = last
>>
>>
>>
>>
>>
>> Feb  8 11:21:38 pi3 systemd[1]: Starting LSB: weewx weather system...
>> Feb  8 11:21:39 pi3 weewx[26841] INFO __main__: Initializing weewx 
>> version 4.4.0
>> Feb  8 11:21:39 pi3 weewx[26841] INFO __main__: Using Python 3.5.3 
>> (default, Nov 18 2020, 21:09:16) #012[GCC 6.3.0 20170516]
>> Feb  8 11:21:39 pi3 weewx[26841] INFO __main__: Platform 
>> Linux-4.19.66-v7+-armv7l-with-debian-9.13
>> Feb  8 11:21:39 pi3 weewx[26841] INFO __main__: Locale is 'en_GB.UTF-8'
>> Feb  8 11:21:39 pi3 weewx[26841] INFO __main__: PID file is 
>> /var/run/weewx.pid
>> Feb  8 11:21:39 pi3 weewx[26845] INFO __main__: Using configuration file 
>> /home/weewx/weewx.conf
>> Feb  8 11:21:39 pi3 weewx[26845] INFO __main__: Debug is 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO weewx.engine: Loading station type 
>> MQTTSubscribeDriver (user.MQTTSubscribe)
>> Feb  8 11:21:39 pi3 weewx[26830]: Starting weewx weather system: weewx.
>> Feb  8 11:21:39 pi3 systemd[1]: Started LSB: weewx weather system.
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Version is 1.6.2
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) Log 
>> level: 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) Log 
>> debug setting: 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) Log 
>> console: False
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) Log 
>> file: None
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> overlap is 0.0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> message_callback_provider_name is user.MQTTSubscribe.MessageCallbackProvider
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> clientid is MQTTSubscribe-9835
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> client_session is True
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) host 
>> is localhost
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) port 
>> is 1883
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> keepalive is 60
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> username is rtl
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> password is set
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Archive topic is None
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) Wait 
>> before retry is 2
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Connected with result code 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Connected flags {'session present': 0}
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Subscribed to mid: 1 is size 1 has a QOS of 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Subscribed to mid: 2 is size 1 has a QOS of 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Subscribed to mid: 3 is size 1 has a QOS of 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Subscribed to mid: 4 is size 1 has a QOS of 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Subscribed to mid: 5 is size 1 has a QOS of 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Subscribed to mid: 6 is size 1 has a QOS of 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Subscribed to mid: 7 is size 1 has a QOS of 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Subscribed to mid: 8 is size 1 has a QOS of 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Subscribed to mid: 9 is size 1 has a QOS of 0
>> Feb  8 11:21:39 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Subscribed to mid: 10 is size 1 has a QOS of 0
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.engine: StdConvert target 
>> unit is 0x1
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.engine: Archive will use data 
>> binding wx_binding
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.engine: Record generation 
>> will be attempted in 'hardware'
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.engine: Using archive 
>> interval of 300 seconds (specified in weewx configuration)
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.restx: StationRegistry: 
>> Station will be registered.
>> Feb  8 11:21:40 pi3 weewx[26845] INFO user.mqtt: service version is 0.22
>> Feb  8 11:21:40 pi3 weewx[26845] INFO user.mqtt: binding to loop
>> Feb  8 11:21:40 pi3 weewx[26845] INFO user.mqtt: topic is weather
>> Feb  8 11:21:40 pi3 weewx[26845] INFO user.mqtt: desired unit system is 
>> METRIC
>> Feb  8 11:21:40 pi3 weewx[26845] INFO user.mqtt: data will be uploaded to 
>> mqtt://ilm:xxx@localhost:1883/
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.restx: Wunderground-PWS: Data 
>> for station IHARJUMA19 will be posted
>> Feb  8 11:21:40 pi3 weewx[26845] INFO user.windy: version is 0.7
>> Feb  8 11:21:40 pi3 weewx[26845] INFO user.windy: Data will be uploaded 
>> to https://stations.windy.com/pws/update
>> Feb  8 11:21:40 pi3 weewx[26845] INFO __main__: Starting up weewx version 
>> 4.4.0
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.engine: Using binding 
>> 'wx_binding' to database 'weewx.sdb'
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.manager: Starting backfill of 
>> daily summaries
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.manager: Daily summaries up 
>> to date
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.engine: Starting main packet 
>> loop.
>> Feb  8 11:21:40 pi3 weewx[26845] INFO weewx.engine: Main loop exiting. 
>> Shutting engine down.
>> Feb  8 11:21:40 pi3 weewx[26845] INFO user.MQTTSubscribe: (Driver) 
>> Disconnected with result code 0
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__: Caught unrecoverable 
>> exception:
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****  could not 
>> convert string to float: 'Light snowfall'
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****  Traceback 
>> (most recent call last):
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewxd", line 157, in main
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****      
>> engine.run()
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 210, in run
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****      
>> self.dispatchEvent(weewx.Event(weewx.NEW_LOOP_PACKET, packet=packet))
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 245, in dispatchEvent
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****      
>> callback(event)
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 594, in new_loop_packet
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****      
>> self.accumulator.addRecord(event.packet, add_hilo=self.loop_hilo)
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/accum.py", line 436, in addRecord
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****      
>> func(self, record, obs_type, add_hilo, weight)
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/accum.py", line 495, in add_value
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****      
>> self[obs_type].addHiLo(val, record['dateTime'])
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/accum.py", line 168, in addHiLo
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****      val = 
>> to_float(val)
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weeutil/weeutil.py", line 1250, in to_float
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****      return 
>> float(x) if x is not None else None
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****  ValueError: 
>> could not convert string to float: 'Light snowfall'
>> Feb  8 11:21:40 pi3 weewx[26845] CRITICAL __main__:     ****  Exiting.
>> On Monday, February 8, 2021 at 3:19:36 AM UTC+2 [email protected] wrote:
>>
>>> It should be doable. I do something similar with a few temperature 
>>> sensors/fields. The fact that you are dealing with string data does add 
>>> some complexity.
>>> First, for the field configuration you will need to set the 
>>> conversion_type = None. Although it is not documented on the wiki, see 
>>> https://github.com/bellrichm/WeeWX-MQTTSubscribe/wiki/Configuring#conversion_type
>>>  
>>> This will stop MQTTSubscribe from trying to convert the incoming data.
>>>
>>> Next, you will need to configure the accumulator for this field/type.  
>>> See, https://github.com/weewx/weewx/wiki/Accumulators. It looks like 
>>> for this field/type you want to set accumulator = firstlast and extractor = 
>>> last.
>>>
>>> Now you should be able to access it via $current. field/type name.
>>>
>>> If you get this working, I’d like to ‘steal’ the details/steps for a 
>>> wiki page.
>>> -rich
>>>
>>> On Sunday, 7 February 2021 at 17:05:51 UTC-5 Tarmo wrote:
>>>
>>>> Can I do it? I have a text in MQTT like "Cloudy with clear spells" 
>>>> which I would like to display on my website. Although, there is no need to 
>>>> store it in the weewx database. I would like to just to update it at every 
>>>> archive interval.
>>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "weewx-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-user/c163329f-7d6a-4be6-a309-a666dea07been%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/weewx-user/c163329f-7d6a-4be6-a309-a666dea07been%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/03991feb-36ab-44b5-afe6-961aecb0144fn%40googlegroups.com.

Reply via email to