Neuigkeiten:

Am Sonntag den 8.12.2024 kann es ab ca. 8:00 Uhr zu kurzzeitigen Einschränkungen / Ausfällen bei den Diensten des FHEM Vereines kommen.
Die Server müssen mal gewartet und dabei neu gestartet werden ;)

Hauptmenü

devstaticon , stateformat

Begonnen von kroonen, 10 September 2024, 22:58:21

Vorheriges Thema - Nächstes Thema

kroonen

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])



rudolfkoenig

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.

kroonen

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

 

eisman

#3
1x FHEM Debian, Homematic,ZigBee,FS20 / 1X Raspberry, ConBee / 5x ESP
1x FHEM Debian, Homematic,ZigBee         / 1X Raspberry, ConBee / 5x ESP
1x FHEM Debian,MQTT                               / 1X Raspberry, i2c,onewire,gpio
1x auf Windows 2012 Hyper-V-S

TomLee

#4
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

kroonen