mrk-its / homeassistant-blitzortung

Custom Component for fetching lightning data from blitzortung.org
MIT License
186 stars 38 forks source link

Counter do not update #74

Closed larronni closed 1 year ago

larronni commented 1 year ago

Yesterday there was a lot of lightning in the area, they do show up on blitzortung.org but not in the Home Assistant integration. No errors in the log. I have tried to restart Home Assistant and the integration with no luck. I did a test installation on a new installation, and it is not updated there either.

Home Assistant 2023.7.1

kdill00 commented 1 year ago

I think something must be wrong with their API. Mine was working fine on 2023.7.1 and it stopped as well. Another location seems to have the same issues on another version of home assistant.

larronni commented 1 year ago

Is there some way to check/test the API for errors?

Mostalk commented 1 year ago

+1

Today integration not working.

bradsjm commented 1 year ago

My quick review indicates they have changed the key, from 418 to 111. I don't see any changes to the encoding so hopefully it should be a quick change on the server by @mrk-its to get it publishing again.

canuckray commented 1 year ago

+1

bl0rp commented 1 year ago

+1

cjramseyer commented 1 year ago

+1

lillesmoelf commented 1 year ago

+1

kongjudas commented 1 year ago

My quick review indicates they have changed the key, from 418 to 111. I don't see any changes to the encoding so hopefully it should be a quick change on the server by @mrk-its to get it publishing again.

Is this something we can change in the existing code until it's updated?

lubos2mlx commented 1 year ago

+1

Mostalk commented 1 year ago

My quick review indicates they have changed the key, from 418 to 111. I don't see any changes to the encoding so hopefully it should be a quick change on the server by @mrk-its to get it publishing again.

Is this something we can change in the existing code until it's updated?

I wrote a small Python code that receives data from blitzortung and decrypts them. Maybe someone can make a temporary MQTT server out of this

import websocket
import json
import geohash

def decode(data):
    e = {}
    d = list(data)
    c = d[0]
    f = c
    g = [c]
    h = 256
    o = h

    for b in range(1, len(d)):
        a = ord(d[b])
        a = d[b] if h > a else e[a] if e.get(a) else f + c
        g.append(a)
        c = a[0]
        e[o] = f + c
        o += 1
        f = a

    return ''.join(g)

def on_message(_, message):
    data = json.loads(decode(message))
    gh = geohash.encode(data['lat'], data['lon'])
    print(data, gh)

def on_open(ws):
    ws.send('{"a":111}')

def main():
    url = "wss://ws8.blitzortung.org"
    print(f'Connecting to {url}')
    ws = websocket.WebSocketApp(url, on_message=on_message)
    ws.on_open = on_open
    ws.run_forever()

if __name__ == "__main__":
    main()
infrat commented 1 year ago

Hi guys! I've successfully launched my instance of intermediate MQTT server with the fix you described here (changed key in ws payload from 418 to 111) as a replacement to the original one hosted by @mrk-its under blitzortung.ha.sed.pl (which is temporarily broken).

Feel free to use my fixed instance under: 94.246.174.183:1885

Now it's live again: Screenshot 2023-07-13 at 14 59 25

Enjoy!


P.S. To use my instance of MQTT service, you only need to change the MQTT host address and port in 206 and 207 line of your /config/custom_components/blitzortung/__init__.py

Screenshot 2023-07-13 at 15 00 55

And don't forget to restart your instance of Home Assistant.

peterservisbot commented 1 year ago

Hi guys! I've successfully launched my instance of intermediate MQTT server with the fix you described here (changed key in ws payload from 418 to 111) as a replacement to the original one hosted by @mrk-its under blitzortung.ha.sed.pl (which is temporarily broken).

Feel free to use my fixed instance under: 94.246.174.183:1885

Now it's live again: Screenshot 2023-07-13 at 14 59 25

Enjoy!

P.S. To use my instance of MQTT service, you only need to change the MQTT host address and port in 206 and 207 line of your /config/custom_components/blitzortung/__init__.py

Screenshot 2023-07-13 at 15 00 55

And don't forget to restart your instance of Home Assistant.

Is this server still running? I seem to be having difficulty!

mohawk2 commented 1 month ago

A slightly tweaked to my preferences version of @Mostalk's excellent decode function:

def decode(data):
    e = {}
    d = list(data)
    c = d[0]
    f = c
    g = [c]
    o = 256
    for b in range(1, len(d)):
        ao = ord(d[b])
        a = d[b] if ao < 256 else e[ao] if e.get(ao) else f + c
        g.append(a)
        c = a[0]
        e[o] = f + c
        o += 1
        f = a
    return ''.join(g)

And in Perl:

sub blitz_decode {
  my ($data) = @_;
  my %e;
  my @d = split //, $data;
  my @g = my $f = my $c = $d[0];
  my $o = 256;
  for my $ind (1..$#d) {
    my $ord = ord($d[$ind]);
    my $str = $ord < 256 ? $d[$ind] : exists $e{$ord} ? $e{$ord} : $f . $c;
    push @g, $str;
    $c = substr $str, 0, 1;
    $e{$o++} = $f . $c;
    $f = $str;
  }
  join('', @g);
}