tofuSCHNITZEL / home-assistant-wienerlinien

A sensor that give you information about departures from a specified Wiener Linien stop.
MIT License
26 stars 8 forks source link

Directions are sometimes changing #8

Open maehmann opened 1 year ago

maehmann commented 1 year ago

Hey,

I have two stops with both directions added to the integration. One of them has only one line, the other one two lines running from the stop.

I set up one "next" and one "first" sensor supplying all four IDs to each of the sensors. Now it sometimes happens that the generated sensors seem to change the platform / direction.

sensor.XXX_first_departure => platform 1 sensor.XXX_first_departure_2 => platform 2

and then it switches:

sensor.XXX_first_departure => platform 2 sensor.XXX_first_departure_2 => platform 1

I think it happens during restarting HA, but not always. However, I'm not 100% sure about that.

Thanks!

Christoph

tofuSCHNITZEL commented 1 year ago

mabye the problem is connected to the stop with two lines? please try the new beta version and specify the line id you are interested in in the config https://github.com/tofuSCHNITZEL/home-assistant-wienerlinien/releases/tag/1.3.0-beta (enable "show beta versions" under "redownload" in hacs)

could you also post the config you are using so I can test it as well?

maehmann commented 1 year ago

Good morning,

thanks for releasing the new Beta. I installed it and will have a look over the weekend. Do you have the new documentation available somewhere with the new setting options?

I have two immediate points:

1) the line 5A has different end stations during the week and the weekends. So i guess it would be better not to use the station name in the generated sensor name. 2) I already miss the countdown attribute which I used to trigger an alarm but of course I can change my automation…

Thanks for the great work! I really like that integration!

my config so far:

sensor:

tofuSCHNITZEL commented 1 year ago

thanks for releasing the new Beta. I installed it and will have a look over the weekend. Do you have the new documentation available somewhere with the new setting options?

https://github.com/tofuSCHNITZEL/home-assistant-wienerlinien/tree/1.3.0-beta

1. the line 5A has different end stations during the week and the weekends. So i guess it would be better not to use the station name in the generated sensor name.

oh, good point. the entity name "in the background" will not change but will be determined by the time the sensor is setup. also the display name will not change - but I guess this could be changed - would this be helpful to you? maybe I use the platform number in the entity name? since this should stay the same for a given stopid? (I need something to distinguish the entities otherwise you cant add a montor for the same line in both directions)

2. I already miss the countdown attribute which I used to trigger an alarm but of course I can change my automation…

yes I thought that people might use it this way - but while developing the version I read in the ha dev docs that the attributes should not change often (which the countdown attribute does) and its also redundant data.

here is a template you could use instead:

{{ 300 > as_timestamp(states('sensor.kardinal_nagl_platz_u3_ottakring_first_departure'))-as_timestamp(now()) }} (next will arrive in less than 5 minutes)

I will also add this to the readme (maybe even blueprints ;)) hopefully this can help you with your automation?

maehmann commented 1 year ago

thanks for releasing the new Beta. I installed it and will have a look over the weekend. Do you have the new documentation available somewhere with the new setting options?

https://github.com/tofuSCHNITZEL/home-assistant-wienerlinien/tree/1.3.0-beta

Thanks!

1. the line 5A has different end stations during the week and the weekends. So i guess it would be better not to use the station name in the generated sensor name.

oh, good point. the entity name "in the background" will not change but will be determined by the time the sensor is setup. also the display name will not change - but I guess this could be changed - would this be helpful to you? maybe I use the platform number in the entity name? since this should stay the same for a given stopid? (I need something to distinguish the entities otherwise you cant add a montor for the same line in both directions)

I get that the sensor name stays the same after it is setup. However, if you restart HA the name might change, correct?. So, I guess it should be changed to some name that always stays identical. You can either use the platform number (1 or 2) or the direction, which is always "H" or "R" from my experience.

Changing the display name to include the current end station might be interesting. Especially for e.g. U1 where the end station changes with every second train.

2. I already miss the countdown attribute which I used to trigger an alarm but of course I can change my automation…

yes I thought that people might use it this way - but while developing the version I read in the ha dev docs that the attributes should not change often (which the countdown attribute does) and its also redundant data.

here is a template you could use instead:

{{ 300 > as_timestamp(states('sensor.kardinal_nagl_platz_u3_ottakring_first_departure'))-as_timestamp(now()) }} (next will arrive in less than 5 minutes)

Thanks! I took a different approach using {{ ((states('sensor.brigittagasse_5a_nestroyplatz_u_first_departure')|as_datetime|as_local - now()).seconds / 60) |int }} to setup the countdown sensor as before. That let me keep the automations the same.

I will also add this to the readme (maybe even blueprints ;)) hopefully this can help you with your automation?

Thanks again for your efforts!