Forward sensor values to external

Hello,

I would like to forward my data from the weather station to an external service, this worked wonderfully until August - unfortunately not anymore since August.
For this I created the following sensor:

#wettermonster.de - automatischer Abgleich -300 Sekunden
- platform: rest
  name: "Wettermonster.de"
  scan_interval: 30
  resource_template: http://upload.wettermonster.de/speichern.php?id=13563XX&schluessel=50XXXXXX20&temperatur={{ states('sensor.aussentemperatur')}}&helligkeit={{ states('sensor.helligkeit')}}&luftdruck={{ states('sensor.luftdruck')}}&UV={{ states('sensor.uv_a')}}

The following message appears in the log file:
That the maximum character length was exceeded… how to change this?

homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity ID: sensor.wettermonster_de. State max length is 255 characters.

Many greetings
Gerald

What weather station brand/model do you have? Not sure if this will help but it will at least make you laugh - and you might glean some ideas from it. Before I discovered Home Assistant I had actually purchased an RPI (RPI 4 w/8Gig of Ram running headless booted off of a 1TB ssd - the ssd helps tremendously in the speed) and installed weewx on it to listen to my AmbientWeather WS-2902 and publish data to various weather websites (this is from my weewx log):

Windy: Published record 2022-11-23 11:10:00 EST (1669219800)
Wunderground-PWS: Published record 2022-11-23 11:10:00 EST (1669219800)
PWSWeather: Published record 2022-11-23 11:10:00 EST (1669219800)
WindGuru: Published record 2022-11-23 11:10:00 EST (1669219800)
AWEKAS: Published record 2022-11-23 11:10:00 EST (1669219800)
Meteoservices: Published record 2022-11-23 11:10:00 EST (1669219800)
Weather365: Published record 2022-11-23 11:10:00 EST (1669219800)
CWOP: Published record 2022-11-23 11:10:00 EST (1669219800)
WeatherCloud: Published record 2022-11-23 11:10:00 EST (1669219800)
OWM: Published record 2022-11-23 11:10:00 EST (1669219800)
WOW: Published record 2022-11-23 11:10:00 EST (1669219800)

Example of my weather station on one of the above websites getting my data:

https://www.awekas.at/en/instrument.php?id=21459

I wanted to publish to wettermonster but got no responses when reaching out to them. Long story short, I then discovered Home Assistant, in order to use the same device (as no other software can run on the host otherwise) - I went the route of Home Assistant Supervised. I had thought about using HA to publish the data instead but no idea how to go about it.

I now have a decent amount of experience with command line sensors, in order to be able to have this on my dashboard, monitoring weewx transmissions to the web sites - each showing the most recent successful transmission data and time only:

(“(5 min)” meaning how often I am sending them the data, etc.)

For example to have a command line sensor that would create the entry for AWEKAS and here is the code for that (first line of the section being “- sensor:” of course):

image

Notice the GREP in the above with the statement “cut -c-255” at the end to limit the string returned to 255 characters… Also you will note the location of the log - I have to change the syslog and weewx.log file locations on the host to /usr/share/hassio/share as that is one of the only places that HA in a container can see on the host (as /share). I actually had figured out to punch a hole in the container to reach to /var/log on the host but every time I did a Home Assistant update I had to go back in and punch the hole in the container again, until someone sugested to me I just move the logs to showehere that HA could see. UGH!)

To determine the “Last Weewx Error:” (sometimes for various reasons the tranmissions won’t go through occassionally), instead of a million if statements in the template I came up with a clever way of using the name of the sensor (from line 1009) in the last error message to then grab text from that related sensor for the display:

Although also using weewx gives me more flexibility you can see it was a real hassle to show the status of those transmissions in Home Assistant, although there is a really great integration for my weather station also in Home Assistant (which I discovered later and am also using - to tell remind me which windows are open and to close them when it is raining, to make lights (in a room that has many windows) less bright if it is really sunny outside, etc). :slight_smile:

Not sure is sharing my setup above was of much help but - and I probably won’t switch away from the way I am doing it now as weewx uses almost no CPU and also has a database being populated with historical weather data as well as it’s own web server etc - AND it appears to be much more robust thatn HA - still running when (not if!) HA crashes - if I wanted to do the same type of thing that you are doing to make the rest api calls to those websites from HA directly - can I see the rest of your code with some information on how you did it?

Hope this helps maybe somewhat and please let me know - thank you!

(P.S. What hardware are you using for HA? This sounds funcky but to get around the 255 character limit of the data being returned to you (if you really need it), get the data back a different way - would you be able to write a program on the host (or even another machine) that accepts command line parameters - that you would instead call from your sensor, and then listen to the data returned by another manner maybe utilizing mqtt?)

Assuming you don’t need the info returned by the REST call, just add

value_template: "OK"

to the definition.

As the error tells, the payload of the call (that makes up the value of your sensor, really) returns probably more than 255 characters, which is not supported.

1 Like

Thanks!
That was the solution!

I use a WEMO D1 Mini with ESPHome and my sensors are on it.

  • BH1750 (brightness)
  • TX23 (anemometer and direction)
  • HTU21D (temperature/air pressure/humidity)
  • BME280 (temperature/air pressure/humidity)
  • VEML6070 (UVA)

Initially, the project “www.wettermonster.de” served as inspiration - that’s why I share my data :wink:

Gerald