stateformat icon with sprint

Begonnen von kroonen, 17 Oktober 2021, 21:45:17

Vorheriges Thema - Nächstes Thema

kroonen

Hi,

When I use stateformat with this I get the nice value of the temperature

{sprintf("%.1f °C", ReadingsVal($name,"temperature",0))}

When  I do is stateformat: temp_temperature, I get the icon form the devstateicon.

I try to combine this in stateformat, but than the icon still works but the value not. Then it prints the code and not the output. Any idea how to solve this?



   stateFormat temp_temperature \
{sprintf("%.1f °C", ReadingsVal($name,"temperature",0))}




xenos1984

This should work:

stateFormat {sprintf("temp_temperature %.1f °C", ReadingsVal($name,"temperature",0))}

kroonen

Almost.

The state give temp_temperature and the right valuu. Only in device overview I only see the icon and not the temperature value


l Buitentemp
Internals:
   FUUID      5ea0a3e9-f33f-5f49-c5f5-18406003d534a0e8
   LASTInputDev mqtt2
   MSGCNT     9112
   NAME       Buitentemp
   NR         23
   STATE      temp_temperature 10.9 °C
   TYPE       dummy
   mqtt2_MSGCNT 9112
   mqtt2_TIME 2021-10-17 22:13:29
   READINGS:
     2021-10-17 22:13:28   humidity        62.00
     2021-10-17 22:13:28   temperature     10.90
Attributes:
   devStateIcon humidity.*:humidity2 temperature.*:temp_temperature
   event-min-interval .*:300
   event-on-change-reading .*
   group      Klimaat
   mqttSubscribe temperature:topic={"oregon/ch3/temperature"} humidity:topic={"oregon/ch3/humidity"}
   room       Buiten
   stateFormat {sprintf("temp_temperature %.1f °C", ReadingsVal($name,"temperature",0))}

Beta-User

Each icon has to have it's own line in STATE. So this should work:
{sprintf("temp_temperature\n %.1f °C", ReadingsNum($name,"temperature",0))}
Other option - use "set magic":
attr DEVICE stateFormat  temp_temperature\
[$name:temperature:r1]°C
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

kroonen

I used the last one, and that works, thnx