openhab / openhab-core

Core framework of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
913 stars 421 forks source link

Ephemeris support in UIs #1577

Open ghys opened 4 years ago

ghys commented 4 years ago

Here I just want to float some ideas about Ephemeris and how UIs can make it more approachable to users.

First I would propose that we rename the service from Ephemeris (a technical naming referring to a library) to something more generic like "Calendar" or similar? - this is the only occurrence of a technical term being used in this list below, note that the service itself could still be named after Ephemeris but I'm only talking about the display name appearing in the Settings here:

image

Next, the Schedule screen in the UI tries to display rules with time-based triggers and conditions in a calendar by analyzing them client-side, this works when the triggers are well-known and easy to figure out (cron, time of day, day of week, etc.) but when Ephemeris gets involved it becomes impossible. So what about introducing an API to get all time occurrences of rules (matching a certain filter like having a "Schedule" tag) in a configurable future period?

wborn commented 4 years ago

I also suggested to change the name to something more people would understand during my review. :wink:

rkoshak commented 4 years ago

It will cause just a little bit of confusion but I agree, Calendar or something like that makes a better name. But that raises a question, whats the difference between Schedule and Calendar? I know the difference but I worry having the two on the same page next to each other might cause some confusion for the new user in a hurry. Unfortunately I don't know that I have a better word to use. Maybe "Holidays and Weekdays" or something like that?

I don't know if this is possible, but I always thought it odd that I had to set the regional settings in two places, once for OH and again for Ephemeris. Is there a way to get the country at least from Regional Settings to get the list of holidays?

ghys commented 4 years ago

It's true that all settings currently defined for the Ephemeris manager service could in fact be considered to be regional (geographical and cultural) settings, and it could IMHO make sense to move them all there, even if they're only used for Ephemeris. That would solve the problem of having to name the Ephemeris settings section because it would be gone.

kaikreuzer commented 4 years ago

If it is possible to combine multiple services under the "Regional Settings" category, I would agree that this could be a good solution.

So what about introducing an API to get all time occurrences of rules (matching a certain filter like having a "Schedule" tag) in a configurable future period?

I'm not sure I fully understand this idea. Could you briefly elaborate, please?

ghys commented 4 years ago

Yes, I believe it could work like this:

This wouldn't be completely accurate i.e. this method wouldn't be able to understand an if block in a script module, but if done properly it would at least allow the Ephemeris modules to have to opportunity to yield occurrences & perform some filtering on them, that would be more generic and wouldn't depend on frontend support.

DeanCording commented 3 years ago

If you are considering changing the name of Ephemeris, can I also suggest changing the references to BankHoliday to something more generic and internationally recognised. Bank Holiday is a predominately UK term. In most other countries, they are Public Holidays.

J-N-K commented 2 years ago

@ghys, does this require core support and if so, what exactly do you need?

ghys commented 2 years ago

Next, the Schedule screen in the UI tries to display rules with time-based triggers and conditions in a calendar by analyzing them client-side, this works when the triggers are well-known and easy to figure out (cron, time of day, day of week, etc.) but when Ephemeris gets involved it becomes impossible. So what about introducing an API to get all time occurrences of rules (matching a certain filter like having a "Schedule" tag) in a configurable future period?

This part has been implemented => https://github.com/openhab/openhab-core/pull/2125 The label changes (and moving around/consolidation of parameters) are only suggestions and can be handled purely in core.

J-N-K commented 2 years ago

Since nobody comes up with a better name, I would keep it for the time being.

Merging "Regional Settings" and "Ephemeris" is difficult and might be even more confusing. In "Regional settings" you can select a location (in coordinates), but there is no way to determine The correct setting for country/city/region from that (and vice versa, setting a city does not allow determining the location). IMO this is difficult to explain, that you have to set both to get the best experience.

Another related issue is that we can't configure additional day-sets via UI. The problem here is that our config-description can't deal with multiple multi-value parameters. Currently it looks like

{
  ...
  "dayset-weekend": [
    "SATURDAY",
    "SUNDAY"
  ],
  ...
}

The config description for the day-set is

<parameter name="dayset-weekend" type="text" required="true" multiple="true">
    <label>Weekend Days</label>
    <description>List of usual non workable days.</description>
    <default>SATURDAY,SUNDAY</default>
</parameter>

What we need is something like

{
  ...
  "dayset-weekend": [
    "SATURDAY",
    "SUNDAY"
  ],
  "dayset-office": [
    "MONDAY",
    "TUESDAY"
  ],
  "dayset-workathome": [
    "WEDNESDAY",
    "THURSDAY",
    "FRIDAY"
  ],
  ...
}

where the names of the days can be chosen by the user. We currently have no way of defining something like that in the config description. Maybe something like

<parameter name="dayset-*" type="text" required="true" multiple="true">
    <label>Days</label>
    <description>List of days in this day-set.</description>
    <default>SATURDAY,SUNDAY</default>
</parameter>

would be a good idea, where a * in the name is interpreted as "parameter can occur more than once, with a unique id that replaces the *". WDYT?

splatch commented 1 year ago

Another related issue is that we can't configure additional day-sets via UI. The problem here is that our config-description can't deal with multiple multi-value parameters.

Maybe dayset instances could be modeled as separate services which are created by user? As far I remember config descriptor can optionally specify factory attribute which in theory should allow to manage configurations provisioned to ManagedServiceFactory (producing ie. DaysetService tracked by EphemerisManager). I never got that concept working properly, especially that UI seem to lack option for pushing a new configuration into runtime.