Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FIP #1

Open
kamaradclimber opened this issue Nov 12, 2023 · 12 comments
Open

Support FIP #1

kamaradclimber opened this issue Nov 12, 2023 · 12 comments

Comments

@kamaradclimber
Copy link
Owner

kamaradclimber commented Nov 12, 2023

FIP is a special case because it contains "tracks" only AND does not publish the program in advance.

It leads to errors to find the current program and out-dated data until the next refresh against the api.

In practice what happens:

  • HA starts and download the fip "grid"
  • we know the current track (and past tracks) and can display it
  • when track change, we don't find what's airing in the api result (because we cache it to avoid querying the api every 30s) => leads to error until next refresh against the api.

Solutions:

  • query the api every 30s. It will exhaust the api key limit of 1000 requests/day in about 8h. We can imagine a complex system with 3 keys used in rotation
  • find a way to get the program in advance
@kamaradclimber
Copy link
Owner Author

Note: I've sent an email to the radio france api support to see if they have advice.

@Nikohomeassistant
Copy link

Hey
Sorry in advance if my remarks make no sense but i have no idea about building integrations, so just take it as user's wish plz :)
If you got the tracks available in the API, can't you create a sensor just for the track ?
we know the current track (and past tracks) and can display it I dont see that.
Also, as a track is most of the time more than 2 minutes long, cant you imagine refreshing it every 60sec ? I understand it would create an error after 16h/day listenning but who does that ? :)
Finally, i guess the radio france logo would make the integration much smarter ;)
I'm aware you just brought that up quickly, great job ! Even if you're the man, i'm happy enough having brought the idea to you ;)
Good luck with that !

@Nikohomeassistant
Copy link

Me, again!
I was also wondering if its easy to change the fact we need to enter API for each radio we add. Talking about that, i miss the few FIP webradios such as FIP groove or FIP reggae :)
Sorry i wish i could do it myself ! I tried and check and its way above my level !

@kamaradclimber
Copy link
Owner Author

kamaradclimber commented Nov 13, 2023

If you got the tracks available in the API, can't you create a sensor just for the track ?

This is what is supposed to exist. There are two entities exposed by the integration:

  • "airing_now" sensor showing the current track/diffusion. It works on a limited manner at the moment for FIP station, reason is described at the top of this issue.
  • a calendar with all known diffusion/tracks. For FIP it only show the past tracks (and updates once every hour).

we know the current track (and past tracks) and can display it I dont see that.
Then what do you see ? Please share a description + logs or screenshot. Please note the "airing now" takes ~1m at startup to display a value.

Also, as a track is most of the time more than 2 minutes long, cant you imagine refreshing it every 60sec ? I understand it would create an error after 16h/day listenning but who does that ? :)

You probably forget that this integration also runs when you don't listen to your radio.

Finally, i guess the radio france logo would make the integration much smarter ;)
The PR for this was merged this morning: home-assistant/brands#4895. You should be able to see the radio france logo in HA at the moment.

Even if you're the man, i'm happy enough having brought the idea to you ;) Good luck with that !
I'm open to all ideas (if possible if you've seen the info your request is present in the API). Please open new issues for each of them to make follow-up easier.

@Nikohomeassistant
Copy link

Is it possible to half solve this issue with a button?
When you push the button, you get the current track updated.

@kamaradclimber
Copy link
Owner Author

It should be technically possible but I would prefer to find an automated solution (I'm waiting for radio france support to get their opinion on what we should do to support this use case).

@Nikohomeassistant
Copy link

But we could push this button automatically only when we play a radio station on a media player

@kamaradclimber
Copy link
Owner Author

Support in https://github.com/kamaradclimber/radio-france-home-assistant/releases/tag/0.3.0 is much better for FIP and its substations: refresh for FIP is done every 2 minutes which means there is a reasonable chance to have up to date info (while keeping the api key usage under the daily limit).

Next improvement will be when the api will publish data in advance, if it happens.

@Nikohomeassistant
Copy link

Hey
Good job !
I get update every 2 minutes indeed but one update out of two is unknown.

@erjonkers
Copy link

Hi there I think @Nikohomeassistant has a good point in an earlier reply. If we'd only call the API when we're actually listening to a station, we'd lower the overall inefficiency of pulling information 24/7.

Even better, we'd increase the accuracy for FIP when the API load is lower; 60s or even lower would be a option I think.

Conditions I could check to make this work is the combination of:

  • Chromecast is set to 'playing'
  • Media url is set to 'fip'

In the setup of the integration it would be required to add mediaplayers and the url used to stream FIP.

@kamaradclimber
Copy link
Owner Author

This is a very valid suggestion, thanks!

I think it corresponds well to a use case specific to FIP: display information when listening to the radio.
However, it would miss other use cases such as powering up the radio when a specific song is aired (something that would have been very useful 30 years ago 😅 ).

I’ll see what I can do

@erjonkers
Copy link

erjonkers commented May 3, 2024

Got it, thanks either way!!

You could make the 'use api based only under these x conditions' optional (default = always on). Users can create their own boolean helper in such a case. And even allow users to tweak the refresh rate. With the caveat that a max of 1000 requests is in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants