joBr99 / nspanel-lovelace-ui

Custom Firmware for NsPanel with the design of HomeAssistant's lovelace UI in mind, works with Tasmota.
GNU General Public License v3.0
895 stars 190 forks source link

[Feature Request] Input / Edit Time and Display #1285

Open san-code opened 1 week ago

san-code commented 1 week ago

FEATURE DESCRIPTION

A clear and concise description of what the feature should do. I want a cardEntities that shows a time with a subpage for editing. the time should be written back to ibroker. like: Weckzeit 10:15 Uhr

↑ ↑ 10:15 ↓ ↓

ADDITIONAL CONTEXT

Add any other context about the problem here.

PANEL / FIRMWARE VERSION

Please add the Panel/Firmware Version you are using (EU, US-L or US-P) Display: EU/53 ioBrokerScript: 4.4.0.12

Armilar commented 1 day ago

Do you mean something like that?

https://forum.iobroker.net/post/1092494

It already exists --> popupTimer

Also works in the cardEntities

Armilar commented 1 day ago

Quick guide

Use this script (TypeScript --> TS): https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/Blockly/Alarm_clock.ts

All data points and alias channels are created automatically

Add a PageItem with the alarm clock alias (your NSPanelTs.ts --> cardEntities or cardGrid)) { id: 'alias.0.NSPanel.AlarmTime', icon: 'alarm', name: 'Wecker', onColor: Red, offColor: Green, useColor: true },

In the data points under 0_userdata.0... you will find the data points for further processing image

This means the whole thing can also be controlled from outside: Data point "Time" are the minutes from 0:00 a.m. This would be 420 minutes (7*60 minutes = 7:00 a.m.) for example Data point "State" is the status of the alarm clock (active/paused)

With the following function, minutes can also be converted into hours and minutes:

function toHoursAndMinutes(totalMinutes) {
  const hours = Math.floor(totalMinutes / 60);
  const minutes = totalMinutes % 60;
  return { hours, minutes };
}
// { hours: 1, minutes: 40 }
console.log(toHoursAndMinutes(100));

If your wishes have been fulfilled, you can close your feature request

Have a nice 1st Advent ;-)

EDIT: Don't forget to create this Boolean data point. When the alarm time is reached, it switches to "true"

// dpAction wird wenn der Wecker gestellt wird auf false geschaltet
// dpAction wird wenn die Weckzeit erreicht ist auf true geschaltet
// Der nachfolgende Datenpunkt muss manuell erstellt werden...
const dpAction: string = '0_userdata.0.example_boolean';
san-code commented 1 day ago

Super, Danke, dass ist genau was ich gesucht habe.