bruxy70 / CZ-Public-Transport

🚍 Home Assistant custom sensor for finding Czech Public Transportation Connections
15 stars 5 forks source link

Add offset configuration option #24

Closed kusha closed 3 years ago

kusha commented 3 years ago

Motivation: walking distance from my home to the bus stop is around 5 minutes. Sensor usually displays a departure that I won't be able to catch.

This commit introduces a new parameter "offset" which is a positive integer value in seconds. On each updated of departures sensor will check availability of the offset parameter and it will add it to the start_time. In the CZPubTran library (not the sensor) there is no value attached to the payload if start_time is None. It is one of the drawbacks of the current implementation as sensors gets current time on home assistant instance and there might be a delay while it will submit the request and update the sensor. Possible workaround is include sensor update time to the offset.

I've introduced a new sensor attribute to display start time with the offset. It might be useful to display sensor data while it it searching for connection and departure time attribute isn't yet available.

kusha commented 3 years ago

Hi, @bruxy70 that is my first attempt to edit someone's custom components. Let me know if I need to modify something (code style or implementation). Also, it wasn't clear to me how I can modify config_flow.py to make it possible to configure offset through the UI setup. Can you suggest me the required changes?