Blackymas / NSPanel_HA_Blueprint

This allows you to configure your complete NSPanel via Blueprint with UI and without changing anything in the code
1.29k stars 241 forks source link

Public transport timetable #811

Open halecivo opened 1 year ago

halecivo commented 1 year ago

Hello,

it would be awesome to see when next train departures in my hall. Line - Destination - time +delay (delay is just nice to have, I could already include it in the time).

For timetable page it would be cool to see something like this: image

But in order to not need to touch the display while putting my shoes on and wondering whether I'm on time, something smaller would be great to have also on the home page.

It seems that most problematic is limit to few characters for a entity state, I am able to print something like "15m - Pra", which tells me that train to Prague leaves in 15 minutes, but it is not very nice. Being able to use template as a label for entity on entity page could help me to at least display "Praha hl. n." "15 m" on a single line.

edwardtfn commented 10 months ago

How is this info available in Home Assistant?

halecivo commented 10 months ago

The data itself comes from REST api sensor, for Prague integrated transportation, I use golemio. Currently, I just combine the data into a string state for template sensor. The problem is that displayed state of the sensor is limited to only a few characters. In order to have "proper" timetable - data could be combined to provide destination, departure, line and possibly also last known position or delay.

rest:
    - resource: https://api.golemio.cz/v2/pid/departureboards?ids=U2142Z301&minutesBefore=-7
      scan_interval: 60
      headers:
        X-Access-Token: >
        <token>
      sensor:
        name: departures
        value_template: "{{ now() }}"
        json_attributes:
           - "departures"

sensor:
    - platform: template
      sensors:
        ricany_departure_1:
          value_template: "{{ state_attr('sensor.departures', 'departures')[0].departure_timestamp.minutes }} m - {{ state_attr('sensor.departures', 'departures')[0].trip.headsign }}: {{ state_attr('sensor.departures', 'departures')[0].route.short_name }}"
grigi commented 10 months ago

I was thinking on how I could use this for my own thing, which is almost the same, but not exactly. We have 2 nearby stops but we use one a lot more than the other.

What if we could allow a button to support text entities, and if you select it (short/long, or one of the 3 shortcut buttons on the home page) it would open a detailed screen which would just render the text.

Could just use monospaced font and fit, e.g. 8 rows of 24 characters each and mock it like so: (with newlines to indicate next row)

PATCHAM
5   Pavillion     6 min
5a  Hollingbury  10 min
52  Town Square  10 min
17  Lancing      14 min
ELDRED
27  Saltdean      3 min
27a Saltdean     23 min

I'm thinking a single multiline text entry would work. That has a max length of 255 which should be enough for that kind of table. (8 × (24+1) = 200) You could extend it with some lightweight markup (like underline or bold/colour) and it would still fit. (not important)

Should be possible to implement, I think?

@halecivo Would that work for you?

grigi commented 10 months ago

Was thinking that a button that triggers an automation that then fetches the data from the API and then calls a service on the panel e.g. send_command_table.

This would also only check the bus api when you want to see it, and you could also send metadata for e.g. font colour or icons to show as the data is now structured.

That would only require a new service and screen for custom presentation.

If you do this, to hide latency it would be useful to send 2 service calls, one to render a screen with no info, then fetch data from API, then send call again updated with the content. And any action on it would cancel it.

edwardtfn commented 10 months ago

The challenge is on Nextion side. There are important limitation to change the screen dynamically. The screen is made of pre-define components with some hard coded attributes not available to be changed programmatically... Like font size, position, etc. I could have multiple pages, for 3 columns, 4 columns, etc., but then it will probably get to another Nextion limitation... memory. :(

grigi commented 10 months ago

Hence my initial suggestion of monospaced text. You can simulate columns by whitespace alignment. So there's not really any concept of "columns" needed for that.

edwardtfn commented 10 months ago

I think that would be quite easy.