Hi
I want to switch charging switch some time before my alarm on android device will be run
i know how to do it except 
I don’t know how to create automatization which will run on condition
i have from android device timestamp which is showing time in millisecond, and I want to take time now
and add to it for example 1800000milisecound which is 30 minutes
for example
time now +18000000 > sensor.sm_g988b_next_alarm_2 —> timestamp from this
can anyone help me how to create it ?
ok i got it 
alias: Alarm Power on morning devices
description: “”
trigger:
- platform: state
entity_id:
- automation.nowa_automatyzacja_8
condition:
- condition: or
conditions:
- condition: and
conditions:
- condition: template
value_template: >-
{{ as_timestamp(now()) + 3600 >
as_timestamp(states(‘sensor.sm_g988b_next_alarm_2’)) }}
- condition: numeric_state
entity_id: sensor.sm_g988b_battery_level_2
below: 10
- condition: or
conditions:
- condition: and
conditions:
- condition: template
value_template: >-
{{ as_timestamp(now()) + 2400 >
as_timestamp(states(‘sensor.sm_g988b_next_alarm_2’)) }}
- condition: numeric_state
entity_id: sensor.sm_g988b_battery_level_2
below: 50
- condition: or
conditions:
- condition: and
conditions:
- condition: template
value_template: >-
{{ as_timestamp(now()) + 1800 >
as_timestamp(states(‘sensor.sm_g988b_next_alarm_2’)) }}
- condition: numeric_state
entity_id: sensor.sm_g988b_battery_level_2
below: 65
- condition: or
conditions:
- condition: and
conditions:
- condition: template
value_template: >-
{{ as_timestamp(now()) + 1200 >
as_timestamp(states(‘sensor.sm_g988b_next_alarm_2’)) }}
- condition: numeric_state
entity_id: sensor.sm_g988b_battery_level_2
below: 85
action:
- service: switch.turn_on
data: {}
target:
entity_id: switch.sonoff_10010a5c16