This code is not trigger my relay, but when “push” “run” button in the automation, the trigger is working.
This is my calendar:
I know the calendars are only updated every 15 minutes. I try to reload automations but nothing changes.
I set calendar to 16:41 and navigate to the created automation:
but only add time is not enough for me, to start and stop my solenoid.
For example I want to start the watering on monday 08:30 and stop at 9:32 and start on thursday 8:30 and stop at 9:32 etc.
Maybe do you know other method to schedule my solenoid?
My other problem is VL53L0X laser distance sensor.
This is a simple ino code, but I don’t know how to send data to Home assistant
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
void setup()
{
// pinMode(9,INPUT_PULLUP);
// digitalWrite(9,HIGH);
Serial.begin(9600);
Wire.begin();
sensor.init();
sensor.setTimeout(500);
// Start continuous back-to-back mode (take readings as
// fast as possible). To use continuous timed mode
// instead, provide a desired inter-measurement period in
// ms (e.g. sensor.startContinuous(100)).
sensor.startContinuous(1000);
}
void loop()
{
int distance =sensor.readRangeContinuousMillimeters();
//int distance =sensor.startContinuous(100);
//distance = distance;
Serial.print("Distance: ");
Serial.print(distance);
Serial.print("mm");
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
Serial.println();
delay(1000);
}
I read many description but no result. Can You help me?
#include <Ethernet.h>
#include <ArduinoHA.h>
#define LED_PIN1 9
#define LED_PIN2 8
#define BROKER_ADDR IPAddress(192,168,1,108)
#define BROKER_USERNAME "mqttuser" // replace with your credentials
#define BROKER_PASSWORD "M*********1"
byte mac[] = {0x00, 0x10, 0xFA, 0x6E, 0x38, 0x4A};
EthernetClient client;
HADevice device(mac, sizeof(mac));
HAMqtt mqtt(client, device);
// "led" is unique ID of the switch. You should define your own ID.
HASwitch led("led");
HASwitch led2("led2");
void onSwitchCommand(bool state, HASwitch* sender)
{
if (sender == &led) {
digitalWrite(LED_PIN1, (state ? HIGH : LOW));
// sender->setState(state); // report state back to the Home Assistant
// the switch1 has been toggled
// state == true means ON state
} else if (sender == &led2) {
digitalWrite(LED_PIN2, (state ? HIGH : LOW));
// sender->setState(state); // report state back to the Home Assistant
// the switch2 has been toggled
// state == true means ON state
}
// digitalWrite(LED_PIN1, (state ? HIGH : LOW));
// sender->setState(state); // report state back to the Home Assistant
}
void setup() {
pinMode(LED_PIN1, OUTPUT);
digitalWrite(LED_PIN1, LOW);
pinMode(LED_PIN2, OUTPUT);
digitalWrite(LED_PIN2, LOW);
// you don't need to verify return status
Ethernet.begin(mac);
// set device's details (optional)
device.setName("Arduino");
device.setSoftwareVersion("1.0.2");
// handle switch state
// led.onCommand(onSwitchCommand);
// led.setName("My LED2"); // optional
led.setName("ledlabel1new");
led.setIcon("mdi:lightbulb");
led.onCommand(onSwitchCommand);
led2.setName("ledlabel2new");
led2.setIcon("mdi:lightbulb");
led2.onCommand(onSwitchCommand);
mqtt.begin(BROKER_ADDR, BROKER_USERNAME, BROKER_PASSWORD);
}
void loop() {
Ethernet.maintain();
mqtt.loop();
}