Shelly Flood

well, since you didn’t fix you code block formatting and based on that info then I’ll assume the following should work:

- platform: template
  sensors:
    shelly_flood_bagno_old:
      friendly_name: Shelly Flood Bagno Filtrato
      value_template: >
        {% if is_state('sensor.shelly_shwt_1_c8b0b9_temperature', 'unavailable') or is_state('sensor.shelly_shwt_1_c8b0b9_temperature', 'unknown') %}
          {{ states.sensor.shelly_flood_bagno_old.state }}
        {% else %}
          {{ states.sensor.shelly_shwt_1_c8b0b9_temperature.state }}
        {% endif %}

I installed one a week ago, the battery still reads 100%… did you update the firmware?

It’s on the latest firmware yes (not beta)

It’s only about 1-2 meters from the AP, so I’m not expecting that that’s the problem, unless the fact that it’s behind the washing machine is the problem, and the washing machine is blocking his signal, so he just goes into an endless loop of trying to connect to WiFi?

I don’t know, I’ve just left it on the desk now in the open, will have to see if that makes a difference.

Yesterday I tried to put the indicated code but the entity was disconnected. Can you only confirm me if the indicated code, if the entity is reachable, really copy the temperature value of this entity

sensor.shelly_shwt_1_c8b0b9_temperature

In a new entity? How often does the copy of the value take place? Can you import every hour? Thank you

Yes, if the entity is not in one of the two states in the “if” portion (unavailable or unknown) AND the entity that is being used (sensor.shelly_shwt_1_c8b0b9_temperature) is correct then it will copy the state of that entity into the new entity (sensor.shelly_flood_bagno_old).

if it is in one of those states it will continue to use the current state of the sensor.shelly_flood_bagno_old.

HOWEVER, if the current state of the sensor.shelly_flood_bagno_old hasn’t been defined yet because the sensor.shelly_shwt_1_c8b0b9_temperature is unknown (because it has always been disconnected) then it will continue to have the state as “unknown” until that sensor.shelly_shwt_1_c8b0b9_temperature comes back online at least once to update the sensor.shelly_flood_bagno_old.

The way the template is constructed right now it will only update when there is a change in the sensor.shelly_shwt_1_c8b0b9_temperature entity.

there is no real easy way to get it to update every hour but you can force it to update every minute by adding {{ now() }} to the template:

{% set update = now() %}
{% if is_state('sensor.shelly_shwt_1_c8b0b9_temperature', 'unavailable') or is_state('sensor.shelly_shwt_1_c8b0b9_temperature', 'unknown') %}
  {{ states.sensor.shelly_flood_bagno_old.state }}
{% else %}
  {{ states.sensor.shelly_shwt_1_c8b0b9_temperature.state }}
{% endif %}

hello I made a change to the code and the detected temperature was copied to the new identity (filtered shelly flood) as you can see from the image. but the moment the identity is disconnected from ha, the filtered identity also loses the connection. In this case it MUST ALWAYS show the last temperature detected. How can we do it? I am attaching the code of the new identity. Thank you

  • platform: template
    sensors:
    shelly_flood_bagno_filtered:
    friendly_name: Shelly Flood Bagno Filtrato
    entity_id: sensor.shelly_flood_bagno_filtrato
    value_template: >
    {% set update = now() %}
    {% if is_state(‘sensor.shelly_shwt_1_c8b0b9’, ‘unavailable’) or is_state(‘sensor.shelly_shwt_1_c8b0b9’, ‘unknown’) %}
    {{ sensor.shelly_flood_bagno_filtrato }}
    {% else %}
    {{ states.sensor.shelly_shwt_1_c8b0b9_temperature.state }}
    {% endif %}

in the code, where is the copy of the temperature between the main sensor and the sensor created by me as secondary to display the old temperature detected?

thanks

bagno bagno1 bagno2 bagno3

sensor.shelly_shwt_1_c8b0b9 --> shelly flood principal temperature
sensor.shelly_flood_bagno_filtrato --> copy of shelly flood principal temperature

It’s getting difficult to continue helping you since 1) you aren’t ever posting the code in the correct format as I had previously asked you to do multiple times and 2) you keep changing the entities that you say are holding the temperature you want to keep.

can you give a screenshot of all the sensors associated with the shelly device including all of their attributes from the states page of dev tools?

And then you need to post the current code you are using in the correct format using three backticks (```) on the line before and after the code block.

it’s ok?

  - platform: template
    sensors:
      shelly_flood_bagno_filtered:
        friendly_name: Shelly Flood Bagno Filtrato
        entity_id: sensor.shelly_flood_bagno_filtered
        value_template: >
          {% set update = now() %}        
          {% if is_state('sensor.shelly_shwt_1_c8b0b9', 'unavailable') or is_state('sensor.shelly_shwt_1_c8b0b9', 'unknown') %}
            {{ sensor.shelly_flood_bagno_filtered }}
          {% else %}
            {{ states.sensor.shelly_shwt_1_c8b0b9_temperature.state }}
          {% endif %}

Yes, thanks.

But that code isn’t the code I suggested you use in my last post above.

Even if you change the name of the sensor from “shelly_flood_bagno_old” to “shelly_flood_bagno_filtered” it’s not the same.

Fix that first.

Then after that can you explain the difference between the “sensor.shelly_shwt_1_c8b0b9_temperature” and the “sensor.shelly_shwt_1_c8b0b9_device_temp” entities?

I would like to copy, at regular intervals, the value of this sensor

sensor.shelly_shwt_1_c8b0b9_temperature

in this new sensor

sensor.shelly_flood_bagno_old ( the sensor to be displayed in a tab)

If the sensor

sensor.shelly_shwt_1_c8b0b9_temperature

1) has a flat battery
2) is disconnected from the internet
3) disconnected from the cloud

the sensor sensor.shelly_flood_bagno_old
must ALWAYS SEE THE LAST DETECTED TEMPERATURE.

This sensor
sensor.shelly_shwt_1_c8b0b9_temperature -> indicates the room temperature

This sensor
sensor.shelly_shwt_1_c8b0b9_device_temp -> indicates the temperature of the device

thanks

Have you done this yet?

I would like to copy, at regular intervals, the value of this sensor

sensor.shelly_shwt_1_c8b0b9_temperature

in this new sensor

sensor.shelly_flood_bagno_old ( the sensor to be displayed in a tab)

If the sensor

sensor.shelly_shwt_1_c8b0b9_temperature

1) has a flat battery
2) is disconnected from the internet
3) disconnected from the cloud

the sensor sensor.shelly_flood_bagno_old
must ALWAYS SEE THE LAST DETECTED TEMPERATURE.

This sensor
sensor.shelly_shwt_1_c8b0b9_temperature -> indicates the room temperature

This sensor
sensor.shelly_shwt_1_c8b0b9_device_temp -> indicates the temperature of the device

thanks

???

I can play the “ignore the post and say the same thing again” game.

I think I’m done now.

Sorry for the mess I'm causing.

This is my code
******************************
  - platform: template
    sensors:
      shelly_flood_bagno_filtered:
        friendly_name: Shelly Flood Filtered Bathroom
        entity_id: sensor.shelly_flood_bath_filtered
        value_template:>
          {% set update = now ()%}
          {% if is_state ('sensor.shelly_shwt_1_c8b0b9', 'unavailable') or is_state ('sensor.shelly_shwt_1_c8b0b9', 'unknown')%}
            {{sensor.shelly_flood_bagno_filtered}}
          {% else%}
            {{states.sensor.shelly_shwt_1_c8b0b9_temperature.state}}
          {% endif%}
*********************************************
hasn't changed since yesterday.

sensor.shelly_shwt_1_c8b0b9 -> Shelly entity with temperature detection

sensor.shelly_flood_bagno_filtered -> new entity that must have stored the same temperature as sensor.shelly_shwt_1_c8b0b9
in case it disconnects from home assistant

If sensor.shelly_shwt_1_c8b0b9 is connected and working, the entity sensor.shelly_flood_bagno_filtered also has the correct temperature.
But by the time this entity disconnects, this sensor.shelly_flood_bagno_filtered no longer displays anything.

I don't know how else to explain myself

I'm sorry