I know it might sound strange but sometimes we need a sensor that is not updated automatically by HA and only updates when we wish so and use homeassistant.update_entity service. Here is the latest topic about it.
Out of interest I tried amelchio’s kind suggestion (good man!) and made it work.
Have a look.
Here’s a way to suppress the sensor from refreshing its value without modifying any code:
Set a sensor’s scan_interval to a very large number. For example, 8640000 seconds will make the sensor refresh its value every 100 days. In practice, if I restart Home Assistant just once during that 100-day period (which would not be unusual), the countdown is reset so, effectively, it never gets to automatically update the sensor. If 100 days seems too short, make it 200 days.
I saw that. My goal was to find out if it’s possible to stop HA polling a sensor.
Setting scan_interval to 0 or -1 doesn’t work and there is no other way to stop polling completely.
A very large number still implies automatic updates.
Anyway, I gained some knowledge about how Python works as it can be applied in many different ways, not only to change polling property.