tlskinneriv / awnet_local

Enables local support for Ambient Weather personal weather stations.
28 stars 5 forks source link

Ambient Weather WS-5000 Lightning Strikes Per Hour Not Available #20

Closed beyondunreal79 closed 1 year ago

beyondunreal79 commented 1 year ago

I have the WS-5000. I noticed that the lightning strikes per day show up in HA, but the lightning strikes per hour show as unavailable. I tired disabling then re enabling the entity, but no change. I also tried to disable the entity, wait for a lightning strike per hour value to show on my console, then re enable the entity, but that didnt help. Any idea on this? image

tlskinneriv commented 1 year ago

Hi! Did lightning strikes per hour become enabled automatically or was it enable it manually? If enabled manually, your WS-5000 may not be providing the data. If enabled automatically, then there may be a bug in the code (I don't have a WS-5000 or lightning sensor to test with, so it's entirely likely). If you would, please grab the latest log entries from the AWNET to HASS add-on and drop them here so I can compare the values the station is sending to what the code is expecting. This should look something like the following:

192.168.1.1 - - [01/Apr/2023 07:22:50] "GET ?stationtype=AMBWeatherV4.3.4&PASSKEY=00:00:00:00:00:00&dateutc=2023-04-01+12:22:49&tempinf=73.6&humidityin=58&baromrelin=30.086&baromabsin=30.015&tempf=71.4&battout=1&humidity=99&winddir=222&windspeedmph=0.2&windgustmph=1.1&maxdailygust=5.8&hourlyrainin=0.000&eventrainin=0.000&dailyrainin=0.000&weeklyrainin=2.591&monthlyrainin=0.000&totalrainin=88.791&solarradiation=42.49&uv=0&batt_co2=1 HTTP/1.1" 200 0

Thanks!

beyondunreal79 commented 1 year ago

I did have to manually add the two lightning entities. Here is the last log: 192.168.1.9 - - [01/Apr/2023 08:36:38] "GET ?stationtype=AMBWeatherV4.3.4&PASSKEY=E8:68:E7:86:C6:24&dateutc=2023-04-01+12:36:37&tempinf=70.3&battin=1&humidityin=49&baromrelin=27.481&baromabsin=27.481&tempf=52.9&battout=1&humidity=99&winddir=207&winddir_avg10m=230&windspeedmph=5.1&windspdmph_avg10m=4.0&windgustmph=5.8&maxdailygust=10.1&hourlyrainin=0.000&eventrainin=0.004&dailyrainin=0.248&weeklyrainin=0.520&monthlyrainin=0.248&yearlyrainin=6.016&lightning_day=2&lightning_time=1680351325&lightning_distance=24&batt_lightning=0&solarradiation=15.86&uv=0&temp1f=47.8&humidity1=65&temp2f=71.4&humidity2=40&temp4f=62.6&humidity4=48&temp6f=63.9&humidity6=38&batt1=1&batt2=1&batt4=1&batt6=1&batt_co2=1 HTTP/1.1" 200 0

tlskinneriv commented 1 year ago

Based on this section of the log:

lightning_day=2&lightning_time=1680351325&lightning_distance=24&batt_lightning=0

it looks like your station is not providing the lighting strikes per hour attribute in the data it's sending. The log should have lightning_hour somewhere in it if it has sent it.

The integration should add entities automatically as it detects them if you are using version 1.0.0 or later.

beyondunreal79 commented 1 year ago

Thats odd. I did in fact have to add both strikes per hour and strikes per day manually. The only one that works is per day.

tlskinneriv commented 1 year ago

Interesting. Having to enable sensors manually was the behavior prior to 1.x. What version of the integration are you running? If you still have old sensors from an upgrade to 1.x for whatever reason, you may need to completely remove the integration, then add it back again. In the event that you do need to remove and add again, it will show no sensors until it gets data from the add-on. Once it gets the first batch of data from the add-on, it should repopulate whatever sensors are provided by the station. Later today I'll try my test environment with the output from your unit and see what should be populating.

beyondunreal79 commented 1 year ago

Ok so my version was way off. I was on v0.3.0. I deleted my weather station, upgraded to v1.0.1. Now I am getting more lightning information. This is better. Just still wondering where strikes per hour are. Reason I need this is I have an automation set up that when lightning strikes, its sends a "lightning in the area" alert to my phone. Then 30 minutes after the last strike another alert that says "lightning all clear". This automation worked fairly well last year but I was using the ambient weather api, not local. I migrated to local during the winter and had the first lightning storm and the alert didnt work. Thats how I discovered the issue with strikes per hour. image

tlskinneriv commented 1 year ago

According to Ambient Weather's support page for the custom upload function, lightning_hour (lightning strikes per hour) is not listed as a parameter, only the 3 sensors you see are listed:

No Parameter Abbreviation Description Parameter Type Default Units of Measure
94 lightning_time Last strike date and time Seconds since January 1, 1970  
95 lightning_day Number of strikes per day count  
96 lightning_distance Distance of last strike float km

It is entirely possible that this value is calculated server side based on the other data provided (it would be fairly easy to do this based on the last lightning strike time). Would you be able to provide data from these 3 sensors and the lightning per hour sensor so that I can deduce a formula for calculating the value? Also, is it lightning strikes per hour (as a rate) or number of lightning strikes in the last hour (as a count)?

The API Docs are where I got the original calculated fields for the integration. I thought this one would be provided by the device, but perhaps not based on the support page.

If you are able to get the data, then feel free to open a feature request issue, and I'll work on getting it programmed in.


As for your automation, you could definitely trigger off of changes in Last Lightning Strike (on change for first notification, not changed for 30 minutes for the second notification). From what I understand, that value should change every time that a lightning strike occurs. You could assume that if it hasn't changed in the last 30 minutes, then there hasn't been any lightning in the last 30 minutes.

beyondunreal79 commented 1 year ago

It was lightning strikes per hour as a total count. It basically started counting up as the strikes came in. If the strikes didn't continue, the number i see would decrease (because it was based on the last hour. What data would you need from me? This is what the app shows

Screenshot_20230401-143341_Ambient Weather

tlskinneriv commented 1 year ago

Was it a count that was rolling (literally within the last 60 minutes) or is it a count of how many that have happened in the current hour (e.g. 1200-1300, 1300-1400, etc.)?

beyondunreal79 commented 1 year ago

Yes, a count within the last hour. So let's say there was 60 strikes in the last hour. As time went on, if there were no new strikes, the count would go down. (Because it kept Calculating the last 60 minutes. So if there were no new strikes, the count decreases. Hope this makes sense

tlskinneriv commented 1 year ago

Based on some data I got in this issue (https://github.com/ambient-weather/api-docs/issues/45), I've developed an equation to calculate this value. Working on getting in implemented.