FHEM Forum

FHEM => English Corner => Thema gestartet von: kroonen am 10 September 2024, 22:58:21

Titel: devstaticon , stateformat
Beitrag von: kroonen am 10 September 2024, 22:58:21
I try to change the stateformat of my tv , to show also the start and end time of a program.

The script is working only de devstateicon is not working anymore, any idea how I can solve this. I want to see the icon and after the icon the text

attr TV devStateIcon on:control_standby@orange:off off:control_standby@grey:on

   stateFormat {
  # Haal de readings op
  my ($startDateTime, $durationSec, $power, $channel, $currentTitle) = (
    ReadingsVal("TV", "ci_startDateTime", ""),
    ReadingsVal("TV", "ci_durationSec", 0),
    ReadingsVal("TV", "power", "off"),  # Default naar 'off'
    ReadingsVal("TV", "channel", "unknown"),
    ReadingsVal("TV", "currentTitle", "unknown")
  );
 
  # Starttijd parsen
  my ($hour, $minute) = ($startDateTime =~ /T(\d{2}):(\d{2})/);
 
  # Duur berekenen in uren en minuten
  my $endTimestamp = time_str2num($startDateTime) + $durationSec;
  my ($endHour, $endMinute) = (strftime("%H", localtime($endTimestamp)), strftime("%M", localtime($endTimestamp)));

  # Begin met power-status, zodat devStateIcon correct werkt
  return sprintf("%s, %s / %s [%02d:%02d-%02d:%02d]",
                 $power, $channel, $currentTitle, $hour, $minute, $endHour, $endMinute);
}

BRAVIA:
  TV                   (on, NPO 3 / NOS Voetbal [22:45-23:20])


Titel: Aw: devstaticon , stateformat
Beitrag von: rudolfkoenig am 11 September 2024, 10:07:57
If I am not mistaken, the state is "on, NPO 3 / NOS Voetbal [22:45-23:20]".
devstateicon currently expects "on" or "off".
It should work if you change it to
on.*:control_standby@orange:off off:control_standby@grey:on
This is just guessing, since i do not have all the details.
"Copy for forum.de" in TV details could help.
Titel: Aw: devstaticon , stateformat
Beitrag von: kroonen am 11 September 2024, 10:57:41
Ok that works, only I see the icon, and I only see the text when I hover over the icon. I would like to see the icon , and near that in the webinterface the text

 
Titel: Aw: devstaticon , stateformat
Beitrag von: eisman am 11 September 2024, 11:55:52
hi,

ICON and TXT 1 (https://forum.fhem.de/index.php?topic=99439.0)
ICON and TXT 2 (https://forum.fhem.de/index.php?topic=38332.0)
ICON and TXT 3 (https://forum.fhem.de/index.php?topic=105598.0)

gruss
Titel: Aw: devstaticon , stateformat
Beitrag von: TomLee am 11 September 2024, 12:15:40
Hallo,

Hack:

ergänze einen Zeilenumbruch in der stateFormat-Definition

return sprintf("%s
 %s / %s [%02d:%02d-%02d:%02d]",$power, $channel, $currentTitle, $hour, $minute, $endHour, $endMinute);

Gruß Thomas
Titel: Aw: devstaticon , stateformat
Beitrag von: kroonen am 11 September 2024, 16:16:53
Yes, that was the trick. Thnx