Initial numeric state of sensor

HI,

Is there a method to set the initial numeric state of a sensor within automation of event_type: homeassistant_start?

Thanks,

Rob.

See if this post helps you out:

Thanks Rpitera,

Had a look, little bit out of my scope of knowledge to use the API.
Reading the topic, it mentions you can’t set the state of the sensor, you can set the state of the sensor via developers tools/states.Hence I’m hoping there is also a simple method to set an initial value on boot up.

Rob.

Maybe this then?

Really appreciated Rpitera,

My eyes did glaze over whilst reading this, seems like a complicated method.
Not sure which way to jump here, thinking I might look at the appdaemon as it seems like it might be the easier way to go with automations.

Rob.

If you’re comfortable with Python, I’d definitely suggest it. Those who are swear by it.

No Python wizard by any means, but know enough to get myself in trouble!
Besides the disclaimer on the above component ie no responsibility for your daughter getting pregnant was a show stopper! :slight_smile:

Thanks again Rpitera and others,

A simple way could be to use the homeassistant_start event trigger in an automation to set the initial values. Something like:

  trigger:
     platform: event
     event_type: homeassistant_start

But how do you set the state?

Oh…you are right. Unfortunately, only the input entities can be set. May be you can use input_slider as an intermediate entity.

Do you have an example of this you could share? I’ve seen the technique mentioned but never seen an example and I’d like to understand it better. No rush - this is just for education on my part!

I have an example in my config. Basically, I am using a Leeo Smart Alert that connects to HA via IFTTT. I can get the temperature and humidity. To update the values from IFTTT, I created two input_slider here and then create a sensor based on these input_sliders here. I had to do this precisely because there is no way (at least that I know of) to update the template_sensors directly.

Thanks; I’ll check this out.