Hello,
My project is the control of the extinction as well as the start of my server.
My server is Mac Pro 2.1 (2006) run Debian 11 and Open Media Vault 6.
The services of my server are Home Assistant, Nextcloud, Ngnix, ESPHome and Minecraft server. The services are run by Docker and Docker is run by Portainer.
I not use my server all day, therefore it’s not necessary to power in permanently.
I will therefore use an ESP-01 (ESP8266) to control the starting and stopping of my server, with variable data from Home Assistant, but also Debian.
I use a clock alarm in Home Assistant, I will use the variable for execute start 1h15 before the alarm. Yes, I use another one automation. Who takes care of charging my phone 1 hour before. So I choose 1h15 to have a margin.
I use this code from active my charger 1h before my alarm, it must be modified to remove another 15 minute.
You have at good idea for the modification ?
template:
- sensor:
- name: "Wake Time 1 Pre"
unique_id: sensor.wake_time_1_pre
device_class: timestamp
state: >
{% set alarm = today_at(states('input_datetime.wake_time_1')) %}
{% set offset = 23 if now() >= alarm else -1 %}
{{ alarm + timedelta(hours=offset) }}
In the ESP, I retrieve the time for the start of my server by this code.
binary_sensor:
- platform: homeassistant
name: "Input wake time Serveur ON From Home Assistant"
entity_id: sensor.wake_time_serveur_on
The first trouble. I send 20h31 and i received 18h31. The ESP Home automatic convert to UTC time ? Because my time is UTC+2
[15:02:26][W][homeassistant.binary_sensor:017]: Can't convert '2022-09-08T18:31:00+00:00' to binary state!
I add the sntp time
time:
- platform: sntp
id: sntp_time
I would like to use C++ to do the start condition, because I think I know how to do it.
Of course, first I have to register my sensor.wake_time_serveur_on in a variable and write in a format equal to that of the sntp
if (id(serveur_power_on) = id(sntp_time)): {
if (id(serveur_on) = low): {
digitalWrite(GPIO0, HIGHT);
delay(3000);
digitalWrite(GPIO0, LOW);
}
}
I get a 3.3V electrical signal in the mac and if there is a signal, I don’t want to start the computer, because that means it is already started.
- platform: gpio
pin: GPIO2
name: "Serveur ON"
id: serveur_on
filters:
- delayed_off: 1000ms
I stop there for today.
If you have better ideas than mine, don’t hesitate.
I’m stuck a bit between using yaml and C++
I find it very easy to call yaml for information but for conditions, I don’t like, and I prefer C++. Except that I can’t integrate it well into ESPHome. To do well, I would like to create a second file with my conditions in C++ and integrate it into the yaml.
Thank you in advance for the help, I specify that I am not an English speaker, so there may be writing errors.