Autor Thema: stateformat icon with sprint  (Gelesen 463 mal)

Offline kroonen

  • Full Member
  • ***
  • Beiträge: 191
    • http://www.kroonen.eu/mobile
stateformat icon with sprint
« am: 17 Oktober 2021, 21:45:17 »
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))}



Offline xenos1984

  • Developer
  • Full Member
  • ****
  • Beiträge: 416
Antw:stateformat icon with sprint
« Antwort #1 am: 17 Oktober 2021, 21:55:36 »
This should work:
stateFormat {sprintf("temp_temperature %.1f °C", ReadingsVal($name,"temperature",0))}

Offline kroonen

  • Full Member
  • ***
  • Beiträge: 191
    • http://www.kroonen.eu/mobile
Antw:stateformat icon with sprint
« Antwort #2 am: 17 Oktober 2021, 22:15:36 »
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))}

Offline Beta-User

  • Developer
  • Hero Member
  • ****
  • Beiträge: 16250
Antw:stateformat icon with sprint
« Antwort #3 am: 17 Oktober 2021, 22:21:36 »
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-T620@Debian 10, 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:MySensors, Weekday-&RandomTimer, Twilight,  AttrTemplate {u.a. mqtt2, mysensors, zwave}

Offline kroonen

  • Full Member
  • ***
  • Beiträge: 191
    • http://www.kroonen.eu/mobile
Antw:stateformat icon with sprint
« Antwort #4 am: 18 Oktober 2021, 09:01:59 »
I used the last one, and that works, thnx