“latest” and “previous” are not versions.
Latest = 1.11.1
Previous = 1.10.1
I am trying to implement an MPU6050 on my Node MCU. When I get everything going, I have no problem connecting, the 6050 is seen on the I2C bus, and the pins are correctly connected. However, I only get 0 back for all my sensors, and 36.5 back for my temp sensor on it at all times.
Seems in my reading ghat this has to do something with some kind of sleep mode perhaps, but can’t figure out how to turn it off.
My code is below, with the new name changes for v 0.88
Any help that could be offered would be greatly appreciated!
esphome:
name: dryer
platform: ESP8266
board: nodemcuv2
arduino_version: recommended
wifi:
ssid: redacted
password: redacted
manual_ip:
static_ip: redacted
gateway: redacted
subnet: redacted
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
mqtt:
broker: redacted
username: redacted
password: redacted
i2c:
sda: D2
scl: D1
scan: True
sensor:
- platform: mpu6050
address: 0x68
accel_x:
name: "MPU6050 Accel X"
accel_y:
name: "MPU6050 Accel Y"
accel_z:
name: "MPU6050 Accel z"
gyro_x:
name: "MPU6050 Gyro X"
gyro_y:
name: "MPU6050 Gyro Y"
gyro_z:
name: "MPU6050 Gyro z"
temperature:
name: "MPU6050 Temperature"
Hi everyone ,
Quick question, if I use the native API to set up EspHome is it possible to set up a 2 way switch setup i.e 1 light 2 switch’s ( 3 way in US). I’ve done this in tasmota with mqtt messages on button presses, but is this possible in someway using the API integration?
Hi,
With HA you can set this quite easy, almost hardware agnostic. Just set an automation that will trigger depending on buttons pressed (can have as many switches as one likes and there is no need for going with 3/4 physical wires to each switch to achieve the same).
- alias: multi way switch
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.binary_sensor_1, binary_sensor.binary_sensor_2, binary_sensor.binary_sensor_3
.#actually can use quite a few different type of switches, not necessarily set as binary sensors (but for binary sensors HA will set them to off even if they don't send a different signal)
to: 'on'
action:
- service: light.toggle # service can also be switch.toggle (if the light is controlled by a switch).
entity_id: light.light_a
Thanks for this , now that you have explained it I feel silly not thinking about using HA to automate the process which is pretty obvious .
Appreciate the help though
FWIW, I attempted this and had similar results with the accelerometer/gyro sensor (MPU6050).
That code I posted (which you quoted) for the arcade table lights works. It wasn’t initially working for me because I had 2 digits transposed in one of the IP addresses, once I fixed that it worked perfectly
I managed to make it work, only trying to add more custom effects now.
I almost forgot, the names of the effects have changed since I flashed my ESP. Check the docs and rename the effects accordingly.
Hi All,
First of all, I’d like to thank Otto and people who work hard on this project, it’s really great.
I need an advice and hope here is the right place to ask.
I have a node (Wemos D1 mini) with a DHT22 sensor attached that configured to send readings every 30 seconds.
My goal is to detect when the humidity goes up quickly (in real life it means a shower is on).
Currently I store previous humidity value/temperature and when a new value arrives, calculate gradient.
It kind of works as by observation I decided on a gradient threshold that indicates a rise that usually happens when a shower is on.
When it’s above the threshold, I use the previous value as a target to decide if the humidity is back to normal.
I also have to ignore fast consecutive readings as it usually happens when the node reconnects to HA.
The thing that bugs me is a sudden significant jitter of humidity that occurs randomly. It’s looks like 75, 84, 74, 75 etc. Only one value, but the resulting gradient is enough to cause false positive.
There is another flaw in my approach - sometimes the rise in humidity is not very sharp but goes in 2 stages. Therefore in the first stage I get a little bit LOWER gradient than I expect to consider it as a shower on event, but the humidity value is pretty high already. And on the next reading I might get gradient above the threshold value, but the previous humidity value is too high already and that decision about normal humidity doesn’t work correctly as I actually need the one that was before that.
I’m thinking of adding two-step gradient, i.e saving 2 previous values/times and calculate gradient between current and -2 value and use -2 humidity as a target if the gradient is above a set threshold.
What do you guys think?
Or maybe there is a better approach to implement?
By the way, currently my esphome node has no fancy functionality defined and all the work is done on HA side. Is there anything that makes sense to implement on the node side in my case?
I believe sensor filters is what you’re looking for. You can then even create custom code that filters/processes the sensor values any way you want.
Thanks Otto, I saw those filters in docs but didn’t dig too deep.
And my concern was whether they filter out only occasional spikes or smoother out the output, in which case I’ll lose a distinctive gradient increases.
Here is my esphome sensor description:
sensor:
- platform: dht
pin: D1
model: dht22
update_interval: 10s
temperature:
name: "bathroom_shower_temperature"
humidity:
name: "bathroom_shower_humidity"
filters:
- filter_nan:
- exponential_moving_average:
alpha: 0.5
send_every: 3
So far it works, will keep an eye on it to see if it resolves my problem with spikes.
I have some questions though:
- Initially I didn’t use send_every: and it sent humidity state once in 15 readings or something. Then I set it to 30 thinking it’s every 30 seconds, but apparently it means every 30th reading, quite a difference. If I set it to 1, it makes no sense as it just repeats incoming values. Is 3 the right value?
- I used to have
update_interval: 30s
, but because of thatsend_every: 3
changed it to 10s.
Therefore currently HA receives humidity values every 30 seconds, but temperature values come every 10 seconds as it’s impossible to set different update_intervals for them. Any way to get both temperature and humidity values in HA every 30?
And still need to find a way to implement that 2-step gradient on esphome level (via lambdas? but I’m not quite sure it is possible as I need access to previous values and times to calculate gradients)
@OttoWinter, I just coded a custom component using your library to solve my fireplace problem, and while it works, the node becomes unavailable while the controller is adjusting the settings. I’m theorizing that it has to do with the use of the delay command in order to get the timing right for the controller. Is there a better way to handle this?
#include "esphome.h"
using namespace esphome;
static const char *TAG = "debug";
const int BLUE_LED = 13; // wifi signal led
const int MASTER_RELAY = 12; // relay 1, setup inline with the others as a master disconnect switch
const int CONTACT_1 = 5; // relay 2
const int CONTACT_2 = 4; // relay 3
const int CONTACT_3 = 15; // relay 4
float fire_level = 0.0;
// for automating a Flare fireplace with a Maxitrol controller
// documentation from the manufacturer can be viewed here: https://i.imgur.com/iPU1glv.png
class FireplaceOutput : public Component, public output::FloatOutput {
public:
void setup() override {
// This will be called by App.setup()
pinMode(BLUE_LED, OUTPUT);
pinMode(MASTER_RELAY, OUTPUT);
pinMode(CONTACT_1, OUTPUT);
pinMode(CONTACT_2, OUTPUT);
pinMode(CONTACT_3, OUTPUT);
// blue led blink on boot just to let me know it has rebooted/started
digitalWrite(BLUE_LED, LOW);
// make sure the fireplace is off on boot
fireplace_off();
digitalWrite(BLUE_LED, HIGH);
}
void connect(){
digitalWrite(MASTER_RELAY, HIGH);
}
void disconnect() {
digitalWrite(MASTER_RELAY, LOW);
}
void fireplace_off() {
connect();
digitalWrite(CONTACT_1, LOW);
digitalWrite(CONTACT_2, LOW);
digitalWrite(CONTACT_3, LOW);
delay(2000);
disconnect();
delay(12000); // takes a while to turn off, and doesn't respond to any other signals during this period
fire_level = 0.0;
}
void fireplace_on() {
connect();
digitalWrite(CONTACT_1, LOW);
digitalWrite(CONTACT_2, HIGH);
digitalWrite(CONTACT_3, LOW);
delay(2000);
disconnect();
delay(30000); // takes a while to turn on, and doesn't respond to any other signals during this period
fire_level = 1.0;
}
void turn_up_fireplace() {
digitalWrite(CONTACT_1, LOW);
digitalWrite(CONTACT_2, HIGH);
digitalWrite(CONTACT_3, HIGH);
}
void turn_down_fireplace() {
digitalWrite(CONTACT_1, HIGH);
digitalWrite(CONTACT_2, HIGH);
digitalWrite(CONTACT_3, LOW);
}
void set_fireplace(float set_level){
if (set_level > fire_level) {
float difference = set_level - fire_level;
float ramp_time = 12000 * difference;
connect();
turn_up_fireplace();
delay(ramp_time);
disconnect();
}
else if (set_level < fire_level) {
float difference = fire_level - set_level;
float ramp_time = 12000 * difference;
connect();
turn_down_fireplace();
delay(ramp_time);
disconnect();
}
fire_level = set_level;
}
void write_state(float state) override {
if (state == 0.0) {
fireplace_off();
}
else {
if (fire_level == 0.0) {
fireplace_on();
}
set_fireplace(state);
}
}
};
Yes you cannot use delays that last that long as it will suspend the entire esphome core loop.
For such delays please use set_timeout
(look for usages in esphome-core code base for examples)
I will try that, thank you @OttoWinter !
How will the library handle concurrent requests? (i.e. another write_state command is called while the previous command is still being executed) Is there any way for me to queue requests if the previous command hasn’t finished executing? (I would rather HA not accidentally leave the fireplace running)
@OttoWinter is it possible to recreate effects for FastLed (ws2812b) using custom component? Something like @Tuckie did in the post above?