Creating a alarm clock

Sorry. You need to remove the initial from the input_boolean and input_number. I have updated the codes. It should remember the value now.

You can use something like this Chromecast Radio with station and player selection and create an automation for when the alarm clock goes start playing one of the radios

@masterkenobi thanks mate.
now it Works, but with one BIG problem.
if you delete home-assistant.log and home-assistant_v2.db all the sliders values are deleted and not stored.
@dale3h had the big solution for this, using MQTT.

the config is:

inside of customize.yaml

automation.persistence_publish:
  friendly_name: "Persistence Publish"
automation.persistence_subscribe_binary:
  friendly_name: "Persistence Subscribe (Binary)"
automation.persistence_subscribe_select_option:
  friendly_name: "Persistence Subscribe (Select Option)"
automation.persistence_subscribe_select_value:
  friendly_name: "Persistence from MQTT (Select Value)"
#inputes
input_number.alarmhour:
  persistent: true
input_number.alarmminutes:
  persistent: true

inside of automations.yaml

- alias: persistence_publish
  initial_state: 'on'
  hide_entity: true
  trigger:
    - platform: event
      event_type: state_changed
  condition:
    - condition: template
      value_template: "{{ trigger.event.data is not none }}"
    - condition: template
      value_template: "{{ trigger.event.data.new_state is not none }}"
    - condition: template
      value_template: "{{ trigger.event.data.new_state.attributes is not none }}"
    - condition: template
      value_template: "{{ trigger.event.data.new_state.attributes.persistent|default(false, true) }}"
    - condition: template
      value_template: "{{ trigger.event.data.old_state is not none }}"
    - condition: template
      value_template: "{{ trigger.event.data.new_state.state != trigger.event.data.old_state.state }}"
    - condition: or
      conditions:
        - condition: template
          value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'automation' }}"
        - condition: template
          value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'input_boolean' }}"
        - condition: template
          value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'input_select' }}"
        - condition: template
          value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'input_number' }}"
        - condition: template
          value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'light' }}"
        - condition: template
          value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'switch' }}"
  action:
    - service: mqtt.publish
      data_template:
        topic: "home-assistant/{{ trigger.event.data.entity_id|replace('.', '/') }}"
        payload: "{{ trigger.event.data.new_state.state }}"
        retain: true

## Persistent Subscriptions
- alias: persistence_subscribe_binary
  initial_state: 'on'
  hide_entity: true
  trigger:
    - platform: mqtt
      topic: home-assistant/automation/+
    - platform: mqtt
      topic: home-assistant/input_boolean/+
    - platform: mqtt
      topic: home-assistant/light/+
    - platform: mqtt
      topic: home-assistant/switch/+
  condition: &subscribe_condition
    - condition: template
      value_template: "{{ ((states[trigger.topic.split('/')[1]][trigger.topic.split('/')[2]]|default).attributes|default).persistent|default(false, true) }}"
    - condition: template
      value_template: "{{ not is_state(trigger.topic|replace('home-assistant/', '')|replace('/', '.'), trigger.payload) }}"
  action: &subscribe_action
    - service_template: "{{ trigger.topic.split('/')[1] }}.turn_{{ trigger.payload|lower }}"
      data_template:
        entity_id: "{{ trigger.topic|replace('home-assistant/', '')|replace('/', '.') }}"

##
- alias: persistence_subscribe_select_option
  initial_state: 'on'
  hide_entity: true
  trigger:
    - platform: mqtt
      topic: home-assistant/input_select/+
  condition: *subscribe_condition
  action:
    - service_template: "{{ trigger.topic.split('/')[1] }}.select_option"
      data_template:
        entity_id: "{{ trigger.topic|replace('home-assistant/', '')|replace('/', '.') }}"
        option: "{{ trigger.payload }}"

##
- alias: persistence_subscribe_select_value
  initial_state: 'on'
  hide_entity: true
  trigger:
    - platform: mqtt
      topic: home-assistant/input_number/+
  condition: *subscribe_condition
  action:
    - service_template: "{{ trigger.topic.split('/')[1] }}.set_value"
      data_template:
        entity_id: "{{ trigger.topic|replace('home-assistant/', '')|replace('/', '.') }}"
        value: "{{ trigger.payload }}"

now you can update your GitHub :wink: it Works like a charm.
for all the peope that want to use this is a best solution, because all data is saved via MQTT

*** this method Works with: automation, input_boolean, input_select, input_number, light e switch***

If you delete the home-assistant_v2.db, you delete the history database. previous states of every entities will be gone.

Anyway, I never had to delete the db. I am using MYSQL database hosted on another machine.

1 Like

Any thoughts or help please? :slight_smile:

I don’t need any input selectors in the frontend nor do I need different radio stations.
I just want to use voice input for setting up the alarm.
Here is my first approach but that one is missing a few things: Set up a radio alarm timer with IFTTT
How can I accomplish it?

Hi,

Maybe not the right place to post this… But I will try anyway :slight_smile:

I need some help with the creation of a car heater function (Living in Sweden) and winter is coming :wink:

I have an outside temp sensor and a switch to connect to the heater in my car.

If the temperature is < 10 i want the heater to start 30 minutes before the actual time to leave.
If the temperature is < 0 i want the heater to start 60 minutes before the actual time to leave.
If the temperature is < -10 i want the heater to start 90 minutes before the actual time to leave.

I also want the heater to run for 30 min after the actual time to leave (if I am late).
It would also be great if it could be started/stopped manually.

I have searched the forum for this, but with no luck…

This is way off my skills, so I trust in you guys :pray:

Hi,

You must create differents automations, depending on the conditions that you want.

Maybe create new topic ask for help.

Hi,

Yes I created a new topic in the forum. Thanks for the advice :slight_smile:

Hi @seriksson,

Can you put the link, just to read, understant what you want and try to help you.

thanks,

@garvarma, Here it is: Car Heater (winter is coming) need coding help!

… to change country? :smiley:

1 Like

@anon35356645
Haha, Me too :wink:

Creating sunrise alarm clock…

My goal is to have “sunrise” alarm clocks using smart led bulbs for all 6 of us in my family. So, there’s a lot of variables involved - different lights at different times on different days. And, eventually the reverse where some lights get gradually dimmer at night (for the younger kids)

When I first looked into smart lights I looked into MiLights and really liked what the guy in this link did:
http://iqjar.com/jar/wake-up-gently-to-gradually-increasing-light/
He made a function (script? automation?) for the the gradual light increase, then he calls it at set times using Cron. However in my case I would need to pass a parameter of which light I was referring too.

I decided not to go the MiLight route because I didn’t like the four zone limit, which brought me to Home Assistant. :slight_smile:

I think from reading this page I can figure out how to assign the times & days. But is it possible to create something (script? automation? effect?) to contain how to do the sunrise effect then call it at a specific time and pass a parameter of which light?

1 Like

Ok, so it looks like maybe I can do this with a Python script?

how can I achieve this?

I’m trying to update to use input_datetime instead, but last night my sunrise alarm went off at midnight so needs a little more work!

1 Like

Used/modified some of the approaches here to trigger a sunrise as my alarm!

1 Like

I have tried to follow your instructions how to create the alarmclock but it looks different. I have removed the input_booleans.
How can I get everything combined and also not showing the badge and not showing “automations” and "input number)?
Mine:


Yours:
333

Put them in a group.