Saving input_boolean states between restarts

I created this panel to schedule a wakeup light to turn on. Unfortunately every time I restart Home Assistant it forgets the input_boolean switch states. The input_number times and input_select selections are almost always saved.

I am using InfluxDB with the following .yaml. Does anyone have any ideas?

  port: 8086
  database: homeassistant
  default_measurement: state
      - input_boolean
      - input_number
      - input_select
      - automation
      - camera
      - media_player
      - remote
      - scene
      - script
      - sun
      - time
      - weather
      - weblink
      - sensor.dark_sky_apparent_temperature
      - sensor.dark_sky_cloud_coverage
      - sensor.dark_sky_cloud_coverage_1
      - sensor.dark_sky_cloud_coverage_2
      - sensor.dark_sky_cloud_coverage_3
      - sensor.dark_sky_cloud_coverage_4
      - sensor.dark_sky_cloud_coverage_5
      - sensor.dark_sky_cloud_coverage_6
      - sensor.dark_sky_cloud_coverage_7
      - sensor.dark_sky_daily_high_apparent_temperature
      - sensor.dark_sky_daily_high_apparent_temperature_1
      - sensor.dark_sky_daily_high_apparent_temperature_2
      - sensor.dark_sky_daily_high_apparent_temperature_3
      - sensor.dark_sky_daily_high_apparent_temperature_4
      - sensor.dark_sky_daily_high_apparent_temperature_5
      - sensor.dark_sky_daily_high_apparent_temperature_6
      - sensor.dark_sky_daily_high_apparent_temperature_7
      - sensor.dark_sky_daily_low_apparent_temperature
      - sensor.dark_sky_daily_low_apparent_temperature_1
      - sensor.dark_sky_daily_low_apparent_temperature_2
      - sensor.dark_sky_daily_low_apparent_temperature_3
      - sensor.dark_sky_daily_low_apparent_temperature_4
      - sensor.dark_sky_daily_low_apparent_temperature_5
      - sensor.dark_sky_daily_low_apparent_temperature_6
      - sensor.dark_sky_daily_low_apparent_temperature_7
      - sensor.dark_sky_daily_max_precip_intensity
      - sensor.dark_sky_daily_max_precip_intensity_1
      - sensor.dark_sky_daily_max_precip_intensity_2
      - sensor.dark_sky_daily_max_precip_intensity_3
      - sensor.dark_sky_daily_max_precip_intensity_4
      - sensor.dark_sky_daily_max_precip_intensity_5
      - sensor.dark_sky_daily_max_precip_intensity_6
      - sensor.dark_sky_daily_max_precip_intensity_7
      - sensor.dark_sky_daily_summary
      - sensor.dark_sky_hourly_summary
      - sensor.dark_sky_humidity
      - sensor.dark_sky_humidity_1
      - sensor.dark_sky_humidity_2
      - sensor.dark_sky_humidity_3
      - sensor.dark_sky_humidity_4
      - sensor.dark_sky_humidity_5
      - sensor.dark_sky_humidity_6
      - sensor.dark_sky_humidity_7
      - sensor.dark_sky_icon
      - sensor.dark_sky_icon_1
      - sensor.dark_sky_icon_2
      - sensor.dark_sky_icon_3
      - sensor.dark_sky_icon_4
      - sensor.dark_sky_icon_5
      - sensor.dark_sky_icon_6
      - sensor.dark_sky_icon_7
      - sensor.dark_sky_minutely_summary
      - sensor.dark_sky_nearest_storm_distance
      - sensor.dark_sky_precip
      - sensor.dark_sky_precip_1
      - sensor.dark_sky_precip_2
      - sensor.dark_sky_precip_3
      - sensor.dark_sky_precip_4
      - sensor.dark_sky_precip_5
      - sensor.dark_sky_precip_6
      - sensor.dark_sky_precip_7
      - sensor.dark_sky_precip_accumulation
      - sensor.dark_sky_precip_accumulation_1
      - sensor.dark_sky_precip_accumulation_2
      - sensor.dark_sky_precip_accumulation_3
      - sensor.dark_sky_precip_accumulation_4
      - sensor.dark_sky_precip_accumulation_5
      - sensor.dark_sky_precip_accumulation_6
      - sensor.dark_sky_precip_accumulation_7
      - sensor.dark_sky_precip_intensity
      - sensor.dark_sky_precip_intensity_1
      - sensor.dark_sky_precip_intensity_2
      - sensor.dark_sky_precip_intensity_3
      - sensor.dark_sky_precip_intensity_4
      - sensor.dark_sky_precip_intensity_5
      - sensor.dark_sky_precip_intensity_6
      - sensor.dark_sky_precip_intensity_7
      - sensor.dark_sky_precip_probability
      - sensor.dark_sky_precip_probability_1
      - sensor.dark_sky_precip_probability_2
      - sensor.dark_sky_precip_probability_3
      - sensor.dark_sky_precip_probability_4
      - sensor.dark_sky_precip_probability_5
      - sensor.dark_sky_precip_probability_6
      - sensor.dark_sky_precip_probability_7
      - sensor.dark_sky_pressure
      - sensor.dark_sky_pressure_1
      - sensor.dark_sky_pressure_2
      - sensor.dark_sky_pressure_3
      - sensor.dark_sky_pressure_4
      - sensor.dark_sky_pressure_5
      - sensor.dark_sky_pressure_6
      - sensor.dark_sky_pressure_7
      - sensor.dark_sky_summary
      - sensor.dark_sky_temperature
      - sensor.dark_sky_wind_bearing
      - sensor.dark_sky_wind_bearing_1
      - sensor.dark_sky_wind_bearing_2
      - sensor.dark_sky_wind_bearing_3
      - sensor.dark_sky_wind_bearing_4
      - sensor.dark_sky_wind_bearing_5
      - sensor.dark_sky_wind_bearing_6
      - sensor.dark_sky_wind_bearing_7
      - sensor.dark_sky_wind_speed
      - sensor.dark_sky_wind_speed_1
      - sensor.dark_sky_wind_speed_2
      - sensor.dark_sky_wind_speed_3
      - sensor.dark_sky_wind_speed_4
      - sensor.dark_sky_wind_speed_5
      - sensor.dark_sky_wind_speed_6
      - sensor.dark_sky_wind_speed_7
      - sensor.load_15m
      - sensor.memory_use_percent
      - sensor.processor_use
      - sensor.since_last_boot
      - sensor.time

I am running HA and InfluxDB in separate docker containers on a laptop running Ubuntu Server 18.04.

input boolean can save states.

You just need to not set it to initial.

If you are using recorder, it may be a bug with input boolean?


To use this feature please make sure that the recorder component is enabled and your entity does not have a value set for initial.

I believe I have this all setup correctly. Recorder has identical the identical configuration to the InfluxDB one I shared in my first post. And here is my declaration of those input_boolean’s. I know it should work… I am clearly overlooking something.


    name: Activate Alarm
    icon: mdi:alarm-check

    name: Monday
    icon: mdi:blank
    name: Tuesday
    icon: mdi:blank
    name: Wednesday
    icon: mdi:blank
    name: Thursday
    icon: mdi:blank
    name: Friday
    icon: mdi:blank
    name: Saturday
    icon: mdi:blank
    name: Sunday
    icon: mdi:blank

I’m not so sure you can make that assumption. Looking at the code for restoring states on the input_boolean, its specifically looking for 1 of 2 keys: restore_state_cache, and recorder. Searching through the influx source, I don’t see it populating that data. The code in input_boolean explicitly checks for ‘restore_state_cache’ first and if it finds it, it returns that state. Otherwise it checks for recorder, if it doesn’t find recorder it stops and returns ‘None’. So we know you aren’t using recorder because your domain name is influxdb, not recorder. I don’t think you are doing anything wrong, I think this is a problem with influxdb or influxdb doesn’t support restoring states.

1 Like

Looking at the Recorder page it lists the relational databases (like MySQL) as being compatible with it. If I have Influx enabled, does recorder stop using SQLite?

I should probably switch to MySQL. I am familiar with that system. Honestly I just added InfluxDB because it was one of the example Docker containers that was often installed alongside Home Assistant and I figured I’d explore Grafana at some point. But if its not going to make HA more reliable then I don’t want it.

The states are never read from Influxdb, so what you have configured for that is not relevant.

The states can be read from either sqllite or mysql, but note that if you do not change the state of the input_boolean more often than the purge_time of the database, the state will be lost and you seem to get a random value.


Thanks for confirming this.

Well that isn’t my problem. I have not specified a purge_time (and I assume it defaults to 10 days) I have been reseting it manually multiple times a day the last 3 days. Everytime I restart the Home Assistant docker container in it resets them.

Maybe I’d be better off writing routines to store those values in and retrieve those values from MQTT?

I actually use an appdaemon app because of these limitiations. It creates its own database and stores the latest state there, which is never purged.

1 Like

Wow! I was unaware of that. Thank you, I will look into it.

To follow up on this, I was able to get this working by adding the following to my /config/appdaemon/apps/app.yaml file. Thank you!

  module: switch_reset
  class: SwitchReset
  file: /config/appdaemon/apps/preserved_states.db
  log: '1'
  delay: 0
    - input_boolean.brian_alarm_clock_status
    - input_number.brian_alarm_clock_hour
    - input_number.brian_alarm_clock_minutes
    - input_select.brian_alarm_clock_light
    - sensor.brian_alarm_clock_day_label
    - input_boolean.brian_alarm_clock_mon
    - input_boolean.brian_alarm_clock_tue
    - input_boolean.brian_alarm_clock_wed
    - input_boolean.brian_alarm_clock_thu
    - input_boolean.brian_alarm_clock_fri
    - input_boolean.brian_alarm_clock_sat
    - input_boolean.brian_alarm_clock_sun

Use this

Oh. That’s intriguing. So instead of having to remember to dig up the /config/appdaemon/apps/app.yaml file, you can define a “persistent” attribute for each object whose state you want to restore on reload. I will give it some thought, I already have the AppDaemon system working, I might like this way better though.

Brian, sorry you had to dust up appdaemon.
This package works perfect. All you have to do is declare persistent:true in the customize.yaml

1 Like

Thank you. persistence.yaml is working just as well. :slight_smile:

Does this just work just by adding persistent: true in customize or should I add ``` in custom_components/sensor folder and adding persistence sensor as per



This is a different component. Thanks for sharing.

I have downloaded the file. where to place the file…
Do i need to place the file in the configuration folder??

I am new to Home assistant, Thanks in advance. is no longer needed as HA will remember your states over a restart now, as long as you have the recorder component enabled.


thank you…i got it worked