FHEM > English Corner

stateformat icon with sprint

(1/1)

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?


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


--- Ende Code ---

xenos1984:
This should work:

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

--- Ende Code ---

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


--- Code: ---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))}

--- Ende Code ---

Beta-User:
Each icon has to have it's own line in STATE. So this should work:

--- Code: ---{sprintf("temp_temperature\n %.1f °C", ReadingsNum($name,"temperature",0))}
--- Ende Code ---
Other option - use "set magic":

--- Code: ---attr DEVICE stateFormat  temp_temperature\
[$name:temperature:r1]°C
--- Ende Code ---

kroonen:
I used the last one, and that works, thnx

Navigation

[0] Themen-Index

Zur normalen Ansicht wechseln