Sensor status

There is a sensor whose status displays several values in the form of text

Example (this is exactly the format, text, colon, text and so on three with spaces as I wrote):
QWE: asd RTY: fgh UIO: jkl

I don’t need everything that is displayed in the status, I can’t understand how it is possible to display only part of the text in the card, please help me solve this problem?

It looks like a dict that is compressed.
Do you know the three letters in front of the colon beforehand?
If you do, then it can be made into a dict that has the form of key:value, like QWE:asd
QWE can then be used to retrieve the value asd

Sorry, I forgot to write that constant values are only text with a colon QWE: and RTY: and UIO:
then a space and the following text changes
Let’s take the first value as an example, here’s how I can add it to the card QWE: asd

Which integration is supplying this sensor?

It could be possible to change its configuration to only supply the value you want.

It should be possible to first do a | replace(": ",":") | split(" ") to get a list, whcih then could be mapped into a dict.
I am sadly a bit rusty in Jinja, because I do most of that stuff in Javascript in Node Red, but I guess some expert here will be able to provide the answer soon. :slight_smile:

This sensor is weather and was created by parsing from the site and has no settings, it just takes a text field from HTML, because of this there is extra text, which I want to exclude when adding to lovelace

So you are using the scrape integration?

This integration does support a value template for refining the returned value: Scrape - Home Assistant

Please share your sensor config correctly formatted for the forum.

Also you have not told us which part of the text value you want to keep.

The command line sensor also supports a value template to alter the output: https://www.home-assistant.io/integrations/command_line/#value_template

- sensor:
     name: "Prognoz Dozdya"
     command: |
        wget -q --user-agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36' "https://yandex.ru/pogoda/maps/nowcast?lat=41.311151&lon=69.279737&via=hnav&le_Lightning=1" -O /dev/stdout | sed 's/>/>\n/g' | grep "weather-maps-fact__nowcast-alert" -A1 | tail -1 | sed 's/<\/div>//g' | sed 's|.*\. ||'
     scan_interval: 900
     value_template: "{{ value.split(' ')[1] }}"

I’m sorry, but I made a mistake above, I gave the code for another sensor
here is the one you need, made with the help of Node-Red

[{"id":"7e2bf4aa6b20d1ee","type":"tab","label":"Зонт от MSN","disabled":false,"info":"","env":[]},{"id":"b66778a04b1c8a8d","type":"inject","z":"7e2bf4aa6b20d1ee","name":"каждый 15 минут","props":[{"p":"payload"}],"repeat":"900","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":130,"y":80,"wires":[["164db81a19e83fc5"]]},{"id":"164db81a19e83fc5","type":"delay","z":"7e2bf4aa6b20d1ee","name":"Случайная задержка","pauseType":"random","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":360,"y":80,"wires":[["8c65129745adaff0"]]},{"id":"8c65129745adaff0","type":"http request","z":"7e2bf4aa6b20d1ee","name":"Запрос осадков сейчас","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.msn.com/ru-ru/weather/life/in-Ташкент,Узбекистан","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"user-agent","valueType":"other","valueValue":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"}],"x":150,"y":180,"wires":[["ea2f230e58971bed","75c3f3d4354c569c"]]},{"id":"ea2f230e58971bed","type":"html","z":"7e2bf4aa6b20d1ee","name":"Выбираем характеристики","property":"payload","outproperty":"payload","tag":"div.lifeIndexBarTitle-E1_1","ret":"text","as":"single","x":460,"y":140,"wires":[["7c9e019817f821f7","5083591b85b6edc5"]]},{"id":"75c3f3d4354c569c","type":"html","z":"7e2bf4aa6b20d1ee","name":"Выбираем значения характеристик","property":"payload","outproperty":"payload","tag":"div.lifeIndexBarSummary-E1_1","ret":"text","as":"single","x":490,"y":200,"wires":[["7c9e019817f821f7","5083591b85b6edc5"]]},{"id":"5083591b85b6edc5","type":"debug","z":"7e2bf4aa6b20d1ee","name":"debug 1","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":950,"y":300,"wires":[]},{"id":"7c9e019817f821f7","type":"merge","z":"7e2bf4aa6b20d1ee","name":"","timeout":"2","x":730,"y":160,"wires":[["12f5ae615fce6ee1"]]},{"id":"12f5ae615fce6ee1","type":"function","z":"7e2bf4aa6b20d1ee","name":"Объединение значений","func":"var array1 = msg.payload[0].payload;\nvar array2 = msg.payload[1].payload;\n\nvar newArray = \"\";\n    for (var i = 0; i < array1.length && i < array2.length; i++) {\n        newArray += array1[i] + \": \" + array2[i]+\"\\r\\n\";\n    }\nmsg.payload = newArray;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":930,"y":160,"wires":[["5083591b85b6edc5","a43a5d592a184bc8"]]},{"id":"a43a5d592a184bc8","type":"ha-sensor","z":"7e2bf4aa6b20d1ee","name":"Одежда по погоде","entityConfig":"12f6313da742a9a0","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1050,"y":60,"wires":[[]]},{"id":"12f6313da742a9a0","type":"ha-entity-config","server":"31f480d3.0e3b28","deviceConfig":"","name":"lifeBar","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Одежда по погоде"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"31f480d3.0e3b28","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

I don’t use Node Red. Someone else will have to help. I have moved your post to the correct forum category.

I could be wrong, but I need help not with Node-Red, but with how to add some information from a sensor created in Node-Red to the card
I’m new to home assistant , but isn’t this done using a template in Lovelace?

Most dashboard cards do not support templates and it would be best to get the data you want in your sensor rather than fudging the display of the data everywhere else.

In the sensor node you have to map the values and create attribute keys. The keys are hard coded but the value is dynamic. I adjusted your flow, see if this works for you.

The only thing you will need to change is the state path. Pick one of the value paths. This is the state the entity will show. You can also have it below as an attribute. Right now it points at payload which is an array and I think it will throw an error.

[{"id":"b66778a04b1c8a8d","type":"inject","z":"7e2bf4aa6b20d1ee","name":"каждый 15 минут","props":[{"p":"payload"}],"repeat":"900","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":130,"y":80,"wires":[["164db81a19e83fc5"]]},{"id":"164db81a19e83fc5","type":"delay","z":"7e2bf4aa6b20d1ee","name":"Случайная задержка","pauseType":"random","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":360,"y":80,"wires":[["8c65129745adaff0"]]},{"id":"8c65129745adaff0","type":"http request","z":"7e2bf4aa6b20d1ee","name":"Запрос осадков сейчас","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.msn.com/ru-ru/weather/life/in-Ташкент,Узбекистан","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"user-agent","valueType":"other","valueValue":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"}],"x":150,"y":180,"wires":[["75c3f3d4354c569c"]]},{"id":"75c3f3d4354c569c","type":"html","z":"7e2bf4aa6b20d1ee","name":"Выбираем значения характеристик","property":"payload","outproperty":"payload","tag":"div.lifeIndexBarSummary-E1_1","ret":"text","as":"single","x":490,"y":200,"wires":[["a43a5d592a184bc8"]]},{"id":"a43a5d592a184bc8","type":"ha-sensor","z":"7e2bf4aa6b20d1ee","name":"Одежда по погоде","entityConfig":"12f6313da742a9a0","version":0,"state":"payload","stateType":"msg","attributes":[{"property":"Зонт","value":"payload[0]","valueType":"msg"},{"property":"На открытом воздухе","value":"payload[1]","valueType":"msg"},{"property":"УФ-индекс","value":"payload[2]","valueType":"msg"},{"property":"Безопасность вождения","value":"payload[3]","valueType":"msg"},{"property":"Одежда","value":"payload[4]","valueType":"msg"},{"property":"Тепловой удар","value":"payload[5]","valueType":"msg"},{"property":"Охлаждение ветром","value":"payload[6]","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":880,"y":200,"wires":[[]]},{"id":"12f6313da742a9a0","type":"ha-entity-config","server":"31f480d3.0e3b28","deviceConfig":"","name":"lifeBar","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Одежда по погоде"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"31f480d3.0e3b28","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]
1 Like

Great, just what I needed, thank you very much