Quantcast
Channel: ESPHome - Home Assistant Community
Viewing all 1486 articles
Browse latest View live

ESPHOME Sonoff 4CH Pro R2 - can 433Mhz be used?

$
0
0

@uzelac wrote:

Prefer ESPHome over Sonoff, but wonder if 433MHz is usable with ESPHome firmware ?
4CH Pro R2 has 433Mhz radio, but it seems it is rendered useless with ESPHome ?
Pitty, if that is the case.
So, is it still possible to pair 433Mhz remotes with ESPHome Sonoff 4CH Pro R2 ?

Thanks

Posts: 12

Participants: 4

Read full topic


Anyone tested the MH-Z16 CO2 Sensor with ESPhome?

Home assistant with raspbery pi 4 lost all usb ports used by esphome

ESPhome switch not working with momentary switch

$
0
0

@sathish wrote:

Hi,

I have ESPhome installed in D1mini board connected to simple 4 channel relay board and binary sensor switches to control relays, all connected to D1mini GPIO pins.

No Issues with relay board, but one binary sensor switch acting weird. I’m using momentary switches with 2 pins, one connected to GPIO pin allocated to binary sensor pin and one to ground. When I press the button, it’s working for only once, later not working no matter how many times I press, but working when I touch the GPIO pin wire with my finger/screw driver/any object, but not ground pin.

I’m searching for this phenomenon for long time, without any answer. Is it because any polarity? Do I need to use any kind of resistor or anything? Don’t know much about electronics.

Posts: 5

Participants: 2

Read full topic

Nextion LCD + homeassistant.service issue

$
0
0

@kolovsky wrote:

I added bt0 in Nextion editor :


and in yaml
              
  - platform: nextion
    page_id: 0
    component_id: 17
    id: lightploshadka
    on_press:
      then:
        - homeassistant.service:
            service: light.turn_on
            data:
              entity_id: light.ploshadka 
    on_release:
      then:
        - homeassistant.service:
            service: light.turn_off
            data:
              entity_id: light.ploshadka           


  - platform: homeassistant   #status update
    id: pl_lights
    entity_id: light.ploshadka 
    on_state:
       then:
         - lambda: 'id(nextiondisplay1).send_command_printf("forecast.bt0.val=%d",id(pl_lights).state);'  

When I press bt0 - everything works as it should. Light is switching on and off. Frontend also shows correct states.

But when I switch light on from HA web (point 1) I can not any more control it from LCD (point 2) ESPhome node detects release event, but nothing happens. Status update works good and bt0 value changes to val=1.


What i am doing wrong?

Posts: 2

Participants: 1

Read full topic

Can I read attribute of entity with Lambda

$
0
0

@fra290 wrote:

I need to read and print on display some attribute of entity.
for exaple: in HA I have one google calendar entity and I want to print on display the Titile:

I have created a text sensor:

text_sensor:
  - platform: homeassistant
    id: calendar
    entity_id: calendar.famiglia

I use printf like this:
it.printf(X, Y, id(font), "%s", id(calendar).state.c_str());
and I have the status… but what is the way to have attribute: message, description, friendly_name, etc.??

thankyou in advance

Posts: 2

Participants: 2

Read full topic

Dummy / Virtual Switches via ESPhome Inside a Smart Switch

$
0
0

@e_town wrote:

I have a couple extra spots in existing electrical boxes where i removed some 3-way swtiches. I have a couple extra MartinJerry swtiches and dimmers. What i would like to do is be able to use the ESPHome long_press and multi_click functionality of a swtich that isn’t actually wired to a light to control other things in my home. Example, long press the down button of the dimmer switch to turn off lights in the basement. Short press down to do another task, etc. I can handle the background automation in HA and NodeRed, I just cant bridge the gap on how to set up a switch in ESPHome that isn’t connected to a GPIO pin.

Example code - https://i.imgur.com/MwoSpUx.png

I can see the buttons as binary sensors for now, but I would like to use the built in automations of long press and multi click.

Thoughts?

Posts: 1

Participants: 1

Read full topic

Help with a CCT (CWWW) light

$
0
0

@BennyB44 wrote:

I have a Mirabella Genio CCT white downlight that requires a different light component setup.

This light runs a pwm on GPIO12 and 14 to a second chip to control the CW WW blend on one PWM and Brightness on the other. It also turns the light off at a duty cycle less than about 10%.

How would I set that up with esphome?

Cheers

Posts: 3

Participants: 2

Read full topic


ESPHome - Arduino Uno/Mega

$
0
0

@CoolDuke wrote:

Just a quick (and maybe stupid) question: would it be somehow possible to use an arduino UNO/Mega with network device with ESPHome? I have a few spots where I don’t have a wifi coverage and therefore would like to use LAN instead of Wifi. It would be nice to make some use of remaining UNOs (+LAN) and the integration of ESPHome in HA is really great.

Don’t really know if ESPHome requires an ESP8266/ESP32 or will also work with an ATMega.

Thx!

Posts: 6

Participants: 4

Read full topic

Esp32-cam always disconnected from HA (its not WiFi problem)

$
0
0

@henaa wrote:

Hi
I used esp32 cam. The connection always disconnected. you can see that from the log
How I fix it?

The esphome code

substitutions:
  # Modify variables based on your settings
  hostname: 'livingroomcam'
  ssid: '***'
  password: '***'
  
esphome:
  name: $hostname
  platform: ESP32
  board: esp32dev
wifi:
  ssid: $ssid
  password: $password
  fast_connect: True
api:
#  reboot_timeout: 0s
ota:
logger:

# ESP32-CAM
esp32_camera:
  external_clock:
    pin: GPIO0
    frequency: 20MHz
  i2c_pins:
    sda: GPIO26
    scl: GPIO27
  data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
  vsync_pin: GPIO25
  href_pin: GPIO23
  pixel_clock_pin: GPIO22
  power_down_pin: GPIO32

  name: livingroomcam
 

The log

[01:03:50][C][esp32_camera:051]:   External Clock: Pin:0 Frequency:20000000
[01:03:50][C][esp32_camera:052]:   I2C Pins: SDA:26 SCL:27
[01:03:50][C][esp32_camera:053]:   Reset Pin: -1
[01:03:50][C][esp32_camera:074]:   Resolution: 640x480 (VGA)
[01:03:50][C][esp32_camera:097]:   JPEG Quality: 10
[01:03:50][C][esp32_camera:099]:   Contrast: 0
[01:03:50][C][esp32_camera:100]:   Brightness: 0
[01:03:50][C][esp32_camera:101]:   Saturation: 0
[01:03:50][C][esp32_camera:102]:   Vertical Flip: ON
[01:03:50][C][esp32_camera:103]:   Horizontal Mirror: ON
[01:03:50][C][esp32_camera:120]:   Test Pattern: NO
[01:03:50][C][api:095]: API Server:
[01:03:50][C][api:096]:   Address: livingroomcam.local:6053
[01:03:51][D][esp32_camera:157]: Got Image: len=21349
[01:04:01][D][esp32_camera:157]: Got Image: len=21268
[01:04:11][D][esp32_camera:157]: Got Image: len=21760
[01:04:23][D][esp32_camera:157]: Got Image: len=21076
[01:04:31][D][esp32_camera:157]: Got Image: len=21354
[01:04:41][D][esp32_camera:157]: Got Image: len=21309
[01:04:55][D][esp32_camera:157]: Got Image: len=21411
[01:05:01][D][esp32_camera:157]: Got Image: len=21548
[01:05:11][D][esp32_camera:157]: Got Image: len=21224
[01:05:22][D][esp32_camera:157]: Got Image: len=21219
[01:05:31][D][esp32_camera:157]: Got Image: len=21517
[01:05:44][D][esp32_camera:157]: Got Image: len=21125
[01:05:51][D][esp32_camera:157]: Got Image: len=21079
[01:06:01][D][esp32_camera:157]: Got Image: len=21045
[01:06:12][D][esp32_camera:157]: Got Image: len=20989
[01:06:21][D][esp32_camera:157]: Got Image: len=21034
[01:06:31][D][esp32_camera:157]: Got Image: len=20876
[01:06:41][D][esp32_camera:157]: Got Image: len=20750
[01:06:51][D][esp32_camera:157]: Got Image: len=20920
[01:07:04][D][esp32_camera:157]: Got Image: len=20950
[01:07:11][D][esp32_camera:157]: Got Image: len=21005
[01:07:25][D][esp32_camera:157]: Got Image: len=20868
[01:07:25][D][api:067]: Disconnecting Home Assistant 0.102.2 (192.168.1.60)
[01:07:31][D][esp32_camera:157]: Got Image: len=21101
[01:07:37][D][api.connection:583]: Client 'Home Assistant 0.102.2 (192.168.1.60)' connected successfully!
[01:07:41][D][esp32_camera:157]: Got Image: len=21003
WARNING Disconnected from API: Timeout while waiting for message response!
INFO Connecting to livingroomcam.local:6053 (192.168.1.67)
INFO Successfully connected to livingroomcam.local
[01:08:09][D][api:067]: Disconnecting Home Assistant 0.102.2 (192.168.1.60)
[01:08:12][D][esp32_camera:157]: Got Image: len=21166
[01:08:19][D][api.connection:583]: Client 'Home Assistant 0.102.2 (192.168.1.60)' connected successfully!
[01:08:23][D][esp32_camera:157]: Got Image: len=21062
[01:08:29][D][api:067]: Disconnecting Home Assistant 0.102.2 (192.168.1.60)
[01:08:31][D][esp32_camera:157]: Got Image: len=21108
[01:08:38][D][api.connection:583]: Client 'Home Assistant 0.102.2 (192.168.1.60)' connected successfully!
[01:08:42][D][esp32_camera:157]: Got Image: len=21059
[01:08:54][D][esp32_camera:157]: Got Image: len=21018
[01:08:57][D][api:067]: Disconnecting Home Assistant 0.102.2 (192.168.1.60)
[01:09:01][D][esp32_camera:157]: Got Image: len=21067
[01:09:02][D][api.connection:583]: Client 'Home Assistant 0.102.2 (192.168.1.60)' connected successfully!

Posts: 6

Participants: 2

Read full topic

TSL2591 integration

$
0
0

@RGN01 wrote:

I wish to use a TSL2591 to measure light levels. I’ve found very useful information at https://github.com/esphome/feature-requests/issues/267 but can’t figure out where to run the pio lib install "Adafruit TSL2591 Library" instruction.

I am running HASS.IO on Ubuntu 18.04.1 LTS and have tried running it on the Ubuntu host after installing python. This gave an error message Error: The /home/rich is not a PlatformIO project.

Please can anyone point me in the correct direction - where should this command be run?

Thanks.

Richard

Posts: 3

Participants: 2

Read full topic

Value sent from esp8266 code not the same as recieved

$
0
0

@swedude wrote:

Hello i have a strange problem, i use custom sensor component and i send 39768182 but i receive 39768184 in HA and i just cant figure out why this is a simplified code that shows the problem
.yaml

esphome:
  name: livingroom
  platform: ESP8266
  board: esp01_1m
  includes:
    - my_custom_sensor.h

wifi:
  ssid: ""
  password: ""

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Livingroom Fallback Hotspot"
    password: "tAksgOaENwUm"

  
captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
    safe_mode: True


sensor:
- platform: custom

  lambda: |-
    auto my_sensor = new MyCustomSensor();
    App.register_component(my_sensor);
    return {my_sensor->temperature_sensor, my_sensor->pressure_sensor};

  sensors:
  - name: "My Custom Temperature Sensor"
    unit_of_measurement: °C
    accuracy_decimals: 0
  - name: "My Custom Pressure Sensor"
    unit_of_measurement: hPa
    accuracy_decimals: 0

my_custom_sensor.h

class MyCustomSensor : public PollingComponent {
 public:

  Sensor *temperature_sensor = new Sensor();
  Sensor *pressure_sensor = new Sensor();

  MyCustomSensor() : PollingComponent(15000) { }

  void setup() override {

  }

  void update() override {
	  unsigned long test_data=39768182;
  

    temperature_sensor->publish_state(test_data);

    pressure_sensor->publish_state(test_data);
  }
};

and this is what i get when i run it (same that shows up in ha)

0000 hPa with 0 decimals of accuracy
[19:52:57][D][sensor:092]: 'My Custom Temperature Sensor': Sending state 3976818
4.00000 °C with 0 decimals of accuracy
[19:52:57][D][sensor:092]: 'My Custom Pressure Sensor': Sending state 39768184.0
0000 hPa with 0 decimals of accuracy
[19:53:12][D][sensor:092]: 'My Custom Temperature Sensor': Sending state 3976818
4.00000 °C with 0 decimals of accuracy
[19:53:12][D][sensor:092]: 'My Custom Pressure Sensor': Sending state 39768184.0
0000 hPa with 0 decimals of accuracy

I just cant figure out why and its messing with the custom sensor I’m trying to write
I’m using the latest version of esphome downloaded just a few days ago
any and all tips big and small are welcome thank you!

Posts: 3

Participants: 3

Read full topic

Desktop tool to test display rendering layout for displays

$
0
0

@Koffeinuser wrote:

Just connected and started to work with an e-paper display from waveshare. Realized that it would be very convenient to have a desktop tool where I could design and render the display layout in real time (or at least closer to it). In reality, interpreting lambda code and draw on a canvas so I know that it looks nice with all expected values that I expect to see (plus frames and other graphics).

Is there any out there - or do any of you have any other suggestion?

Posts: 1

Participants: 1

Read full topic

Motor control for turntable possible?

$
0
0

@hostrup wrote:

Hi!
I am new to both home-assistant - and i have stumbled upon esphome - which has got me thinking of all kinds of things that i want to automate.

I am a bit of an “audiophile” - and i like to listen to oldschool records.
My record player is upgraded with a dc motor - from a company called origin live.
That means my Turntable is driven by a DC motor. The specification of the motor is not named - but it is hear say that they are of type A-max 110173 from maxon.

I believe it’s a brushless motor.

Today i have an external psu - that goes into the Origin Live controlbox - and from there flows the current to the motor.

The control is really simple - as i only has 2 “modes” 33 and 45 rpm - they are “tuned” by 2 variable potentiometers - that i can turn in either direction - to control speed of the currrent setting.

the psu is 12

without knowing much about electronics - it seems that they simply change the voltage going to the motor - and depending on voltage - the motor will run in the “correct” rpms

There are no verification - so i have to manually adjust it to the right speed.

i dont know if there is more to it than this - if so - would i be possible to create an esphome (esp32) with some sort of motor controller board - where you can control the output?

because- then i could control the speed from inside home-assitant - and of course - turning it on an of etc.

Br
Ronni

Posts: 2

Participants: 2

Read full topic

Esp32 cam + PIR motion - not show real PIR status

$
0
0

@henaa wrote:

Hi
Basically the camera works great. the PIR turn on and I see it in the HA
The problem - the PIR did not show the real status
for example - its turn OFF and immediately turn ON (not have any motion near the PIR)
This pattern happens every 15-30s
I check the PIR on d1 mini pro and it work great.
I want to be connected to esp32 cam
What wrong with the code ?

11:58:18][D][esp32_camera:157]: Got Image: len=13427
[11:58:25][D][esp32_camera:157]: Got Image: len=13509
[11:58:33][D][binary_sensor:036]: 'PIR Sensor456': Sending state OFF
[11:58:34][D][binary_sensor:036]: 'PIR Sensor456': Sending state ON
[11:58:35][D][esp32_camera:157]: Got Image: len=13413
[11:58:45][D][esp32_camera:157]: Got Image: len=13528
[11:58:52][D][binary_sensor:036]: 'PIR Sensor456': Sending state OFF
[11:58:54][D][binary_sensor:036]: 'PIR Sensor456': Sending state ON
[11:58:55][D][esp32_camera:157]: Got Image: len=13351
[11:59:05][D][esp32_camera:157]: Got Image: len=13443
substitutions:
  # Modify variables based on your settings
  hostname: 'testcam'
  ssid: '****'
  password: '****'
  
esphome:
  name: $hostname
  platform: ESP32
  board: esp32dev
wifi:
  ssid: $ssid
  password: $password
  fast_connect: true
  reboot_timeout: 45min
  manual_ip:
    static_ip: 192.168.1.70
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns1: *****
    dns2: *****
api:
  reboot_timeout: 0s
ota:
logger:

# ESP32-CAM
esp32_camera:
  external_clock:
    pin: GPIO0
    frequency: 20MHz
  i2c_pins:
    sda: GPIO26
    scl: GPIO27
  data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
  vsync_pin: GPIO25
  href_pin: GPIO23
  pixel_clock_pin: GPIO22
  power_down_pin: GPIO32

  name: testcam
  
binary_sensor:
  - platform: gpio
    pin: GPIO12
    name: "PIR Sensor456"
    device_class: motion

Posts: 1

Participants: 1

Read full topic


Reflash esphome device with tuya-convert

$
0
0

@BradAU wrote:

Hi

I have an issue with a Kogan smart plug that I flashed with esphome using tuya-convert, that has been working perfectly.

I’m changing all my esphome devices to have static ip addresses and in my haste to finish accidentally flashed one with the wrong details and now can’t access it.

It has the static_ip set to 1.0.1.63 but the gateway address is correct at 10.0.1.1, every time I try to upload correct firmware with the use_address set with the hostname it finds the ip address 1.0.1.63 so can’t connect.

In desperation after nearly 2 hours trying different network settings and other things I decided to just re=flash with tuya-convert and set it up from scratch, but can’t get it into pairing mode either.

Does anyone know how I can either force a esphome flash ota or put the device into pairing mode so I can re-flash with tuya-convert?

Posts: 1

Participants: 1

Read full topic

Need help for Pump Control

$
0
0

@IngoNRW wrote:

Hello,

i try to control a pump with two switches.

if the box become full level (water max is State On) the pump should start and if the water level becomes low (water min State ist OFF) the pump should switch off
Who can help me to realize it in esphome .
I tried

binary_sensor:
  - platform: status
    name: "ESP-Keller-02 System Status"

  - platform: gpio
    name: "water_min"
    id: "water_min"
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 4
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: true
    on_turn_off:
    - switch.turn_off:pump
    

  - platform: gpio
    name: "water_max"
    id: "water_max"
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 5
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: true
    on_turn_on:
    - switch.turn_on:pump

switch:
  - platform: gpio
    pin: D7
    id: pump
    name: "pump"
    inverted: true 

Posts: 2

Participants: 2

Read full topic

ESPhome - Wemos D1 mini pro v2 & SHT30 - Communication with SHT3xD failed!

$
0
0

@the1ne wrote:

Hi,

first of all i am a noob regarding home assistant but i read a lot and got it up and running.
But now ii have problems im trying to solve since 2 days searching the inet and the forum but i cannot get it working.

I bought the wemos d1 mini pro and some mini shields for my first tproject building up an outdoor weather station. Thought its a good idea to start with shields i can put on each other to get into buiding more complex stuff later on.

The stuff i bought:
https://www.wemos.cc/en/latest/d1/d1_mini_pro.html
https://www.wemos.cc/en/latest/d1_mini_shiled/sht30.html

picture of the mini and sensors ( sht30 connected wth the cable, pressure and anbient light on top of the mini pro):

I first installed hassio on a nuc -working
then add ESPhome addon -working
Afterwards i made my first simple yamls -working
and updated the wemos mini -working

But now i wanted to add more sensors for temperature (sht30), barometric pressure (HP303B) and the ambient light (BH1750FVI). But im struggling at the first step connecting the sht30 mini shield.

Im using the i2c interface to connect the shield to the mini and tried different approaches to set sda and scl and the adress but i always get the message: Communication with SHT3xD failed!

I got the combination running on Arduino therefor i thought i did the configuration righttherefor i dont know whats going wrong here.

the scratch is looking like this:

esphome:
  name: out_tempfeuchtdruck
  platform: ESP8266
  board: d1_mini_pro

wifi:
  ssid: "ssid"
  password: "password"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "ssid"
    password: "password"
 
i2c:
  sda: 2
  scl: 3
  scan: True
  id: bus_a

sensor:
  - platform: sht3xd
    address: 0x45
    i2c_id: bus_a
    temperature:
      name: "Living Room Temperature"
      id: "temperature"
    humidity:
      name: "Living Room Humidity"
      id: "humidity"
    update_interval: 10s



captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
INFO Reading configuration /config/esphome/out_tempfeuchtdruck.yaml...
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d /config/esphome/out_tempfeuchtdruck
Processing out_tempfeuchtdruck (board: d1_mini_pro; framework: arduino; platform: espressif8266@2.2.3)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 16MB Flash
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.2
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
|   |-- <ESP8266WiFi> 1.0
|-- <ESPAsyncWebServer-esphome> 1.2.6
|   |-- <ESPAsyncTCP-esphome> 1.2.2
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <Wire> 1.0
|-- <DNSServer> 1.1.1
|   |-- <ESP8266WiFi> 1.0
Compiling /data/out_tempfeuchtdruck/.pioenvs/out_tempfeuchtdruck/src/main.cpp.o
Linking /data/out_tempfeuchtdruck/.pioenvs/out_tempfeuchtdruck/firmware.elf
Building /data/out_tempfeuchtdruck/.pioenvs/out_tempfeuchtdruck/firmware.bin
Retrieving maximum program size /data/out_tempfeuchtdruck/.pioenvs/out_tempfeuchtdruck/firmware.elf
Checking size /data/out_tempfeuchtdruck/.pioenvs/out_tempfeuchtdruck/firmware.elf
DATA:    [=====     ]  45.1% (used 36916 bytes from 81920 bytes)
PROGRAM: [====      ]  39.1% (used 407936 bytes from 1044464 bytes)
Creating BIN file "/data/out_tempfeuchtdruck/.pioenvs/out_tempfeuchtdruck/firmware.bin" using "/data/out_tempfeuchtdruck/.pioenvs/out_tempfeuchtdruck/firmware.elf"
========================= [SUCCESS] Took 2.80 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of out_tempfeuchtdruck.local
INFO  -> 192.168.1.xxx
INFO Uploading /data/out_tempfeuchtdruck/.pioenvs/out_tempfeuchtdruck/firmware.bin (412096 bytes)
Uploading: [============================================================] 100% Done...


INFO Waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from out_tempfeuchtdruck.local using esphome API
WARNING Error resolving IP address of out_tempfeuchtdruck.local. Is it connected to WiFi?
WARNING (If this error persists, please set a static IP address: https://esphome.io/components/wifi.html#manual-ips)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error resolving IP address: Error resolving address with mDNS: Did not respond. Maybe the device is offline., [Errno -5] No address associated with hostname). Re-Trying in 1 seconds
WARNING Error resolving IP address of out_tempfeuchtdruck.local. Is it connected to WiFi?
WARNING (If this error persists, please set a static IP address: https://esphome.io/components/wifi.html#manual-ips)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error resolving IP address: Error resolving address with mDNS: Did not respond. Maybe the device is offline., [Errno -5] No address associated with hostname). Re-Trying in 1 seconds
INFO Connecting to out_tempfeuchtdruck.local:6053 (192.168.1.30)
INFO Successfully connected to out_tempfeuchtdruck.local
[22:58:29][I][app:100]: ESPHome version 1.14.3 compiled on Jan 26 2020, 22:57:53
[22:58:29][C][wifi:415]: WiFi:
[22:58:29][C][wifi:283]:   SSID: 

[redacted]
[22:58:29][C][wifi:284]:   IP Address: 192.168.1.xxx
[22:58:29][C][wifi:286]:   BSSID: 

[redacted]
[22:58:29][C][wifi:287]:   Hostname: 'hostname'
[22:58:29][C][wifi:291]:   Signal strength: -58 dB ▂▄▆█
[22:58:29][C][wifi:295]:   Channel: 5
[22:58:29][C][wifi:296]:   Subnet: 255.255.255.0
[22:58:29][C][wifi:297]:   Gateway: 192.168.1.xxx
[22:58:29][C][wifi:298]:   DNS1: 192.168.1.xxx
[22:58:29][C][wifi:299]:   DNS2: (IP unset)
[22:58:29][C][i2c:028]: I2C Bus:
[22:58:29][C][i2c:029]:   SDA Pin: GPIO2
[22:58:29][C][i2c:030]:   SCL Pin: GPIO3
[22:58:29][C][i2c:031]:   Frequency: 50000 Hz
[22:58:29][I][i2c:033]: Scanning i2c bus for active devices...
[22:58:29][I][i2c:049]: Found no i2c devices!
[22:58:29][C][logger:175]: Logger:
[22:58:29][C][logger:176]:   Level: DEBUG
[22:58:29][C][logger:177]:   Log Baud Rate: 115200
[22:58:29][C][logger:178]:   Hardware UART: UART0
[22:58:29][C][sht3xd:034]: SHT3xD:
[22:58:29][C][sht3xd:035]:   Address: 0x45
[22:58:29][E][sht3xd:037]: Communication with SHT3xD failed!
[22:58:29][C][sht3xd:039]:   Update Interval: 10.0s
[22:58:29][C][sht3xd:041]:   Temperature 'Living Room Temperature'
[22:58:29][C][sht3xd:041]:     Unit of Measurement: '°C'
[22:58:29][C][sht3xd:041]:     Accuracy Decimals: 1
[22:58:29][C][sht3xd:041]:     Icon: 'mdi:thermometer'
[22:58:29][C][sht3xd:042]:   Humidity 'Living Room Humidity'
[22:58:29][C][sht3xd:042]:     Unit of Measurement: '%'
[22:58:29][C][sht3xd:042]:     Accuracy Decimals: 1
[22:58:29][C][sht3xd:042]:     Icon: 'mdi:water-percent'
[22:58:29][C][captive_portal:169]: Captive Portal:
[22:58:29][C][ota:029]: Over-The-Air Updates:
[22:58:29][C][ota:030]:   Address: out_tempfeuchtdruck.local:8266
[22:58:29][C][api:095]: API Server:
[22:58:29][C][api:096]:   Address: out_tempfeuchtdruck.local:6053

I hope anybody can help me with this case. I like home assistant a lot but its hard to struggle with the first simple project ;-(

Thx a lot in advance!

Posts: 3

Participants: 1

Read full topic

Working 433mhz sensor receiver (wh2 fineoffset)

$
0
0

@swedude wrote:

Hello i adapted this code: https://github.com/lucsmall/BetterWH2

To work on esphome (esp8266), i converted it from polling to interrupt and did some other stuff and its working with the sensors i have.

Give it a try if you are interested!

I’m running this on a esp-01 with the receiver connected to pin 3(rx), not ideal i know but i have to use all the spare esp-01 i have for something, if you are using some other esp module change to a better pin here: attachInterrupt(3, ext_int_1, CHANGE);

I have tested this with LR45B and RX470C-V01 receivers
Best of luck!

433_sensor.yaml

esphome:
  name: 433_sensor
  platform: ESP8266
  board: esp01_1m
  includes:
    - 433_sensor.h

wifi:
  ssid: ""
  password: ""

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "433_sensor Fallback Hotspot"
    password: "tAksgOaENwUm"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
    safe_mode: True


sensor:
- platform: custom
  lambda: |-
    auto my_sensor = new MyCustomSensor();
    App.register_component(my_sensor);
    return {my_sensor->sensor1, my_sensor->sensor2};

  sensors:
  - name: "temp"
    unit_of_measurement: C
    accuracy_decimals: 1


  - name: "humidity"
    unit_of_measurement: '%'
    accuracy_decimals: 0
    



text_sensor:
- platform: custom
  lambda: |-
    auto last_sensor_data = new Last_sensor_data();
    App.register_component(last_sensor_data);
    return {last_sensor_data};

  text_sensors:
    name: "last_sensor_data"

433_sensor.h

char have_data;
char have_data_string;
std::string my_data;
float temp;
float hum;


class MyCustomSensor : public PollingComponent {
  public:


    Sensor *sensor1 = new Sensor();
    Sensor *sensor2 = new Sensor();
//Based on code from: https://github.com/lucsmall/BetterWH2
//converted from polling to interupt and adjusted to compile with esphome by Swedude




    // 1 is indicated by 500uS pulse
    // wh2_accept from 2 = 400us to 3 = 600us
#define IS_HI_PULSE(interval)   (interval >= 350 && interval <= 750)
    // 0 is indicated by ~1500us pulse
    // wh2_accept from 7 = 1400us to 8 = 1600us
#define IS_LOW_PULSE(interval)  (interval >= 1200 && interval <= 1700)
    // worst case packet length
    // 6 bytes x 8 bits =48
#define IDLE_HAS_TIMED_OUT(interval) (interval > 1150)
    // our expected pulse should arrive after 1ms
    // we'll wh2_accept it if it arrives after
    // 4 x 200us = 800us
#define IDLE_PERIOD_DONE(interval) (interval >= 800)

#define GOT_PULSE 0x01
#define LOGIC_HI  0x02

    static void ICACHE_RAM_ATTR ext_int_1()
    {

      static uint16_t pulse;
      static byte wh2_flags;
      static byte wh2_accept_flag;
      static byte wh2_packet_state;

      static byte wh2_packet[5];
      static byte wh2_calculated_crc;
      static boolean wh2_valid;
      static unsigned long last;
      static unsigned long micros_now;
      static byte sampling_state = 0;
      static byte packet_no, bit_no, history;
      micros_now = micros();
      pulse = micros_now - last;
      last = micros_now;



      switch (sampling_state) {
        case 0: // waiting

          if (IS_HI_PULSE(pulse)) {
            wh2_flags = GOT_PULSE | LOGIC_HI;
            sampling_state = 1;

          } else if (IS_LOW_PULSE(pulse)) {
            wh2_flags = GOT_PULSE; // logic low

          } else {
            sampling_state = 0;
          }
          break;
        case 1: // observe 1ms of idle time

          if (IDLE_HAS_TIMED_OUT(pulse)) {
            sampling_state = 0;
            wh2_packet_state = 1;

          } else if (IDLE_PERIOD_DONE(pulse)) {
            sampling_state = 0;
          }
          else
          {
            sampling_state = 0;
            wh2_packet_state = 1;
          }
          break;
      }

      //----------------------------------------------------
      if (wh2_flags) {

        //----------------------------------------------------

        // acquire preamble
        if (wh2_packet_state == 1) {
          // shift history right and store new value
          history <<= 1;
          // store a 1 if required (right shift along will store a 0)
          if (wh2_flags & LOGIC_HI) {
            history |= 0x01;
          }

          // check if we have a valid start of frame
          // xxxxx110
          if ((history & B00000111) == B00000110) {
            // need to clear packet, and pulseers
            packet_no = 0;
            // start at 1 becuase only need to acquire 7 bits for first packet byte.
            bit_no = 1;
            wh2_packet[0] = wh2_packet[1] = wh2_packet[2] = wh2_packet[3] = wh2_packet[4] = 0;
            // we've acquired the preamble
            wh2_packet_state = 2;
            history = 0xFF;
          }
          wh2_accept_flag = false;
        }
        // acquire packet
        else if (wh2_packet_state == 2) {
          wh2_packet[packet_no] <<= 1;
          if (wh2_flags & LOGIC_HI) {
            wh2_packet[packet_no] |= 0x01;
          }
          bit_no ++;
          if (bit_no > 7) {
            bit_no = 0;
            packet_no ++;
          }
          if (packet_no > 4) {
            // start the sampling process from scratch
            wh2_packet_state = 1;

            wh2_accept_flag = true;
          }
        }
        else
        {
          wh2_accept_flag = false;
        }

        //---------------------------------------------

        if (wh2_accept_flag) {

          int Sensor_ID = (wh2_packet[0] << 4) + (wh2_packet[1] >> 4);
          int humidity = wh2_packet[3];
          int temperature = ((wh2_packet[1] & B00000111) << 8) + wh2_packet[2];
          // make negative
          if (wh2_packet[1] & B00001000) {
            temperature = -temperature;
          }
          uint8_t crc = 0;
          uint8_t len = 4;
          uint8_t *addr = wh2_packet;
          // Indicated changes are from reference CRC-8 function in OneWire library
          while (len--) {
            uint8_t inbyte = *addr++;
            for (uint8_t i = 8; i; i--) {
              uint8_t mix = (crc ^ inbyte) & 0x80; // changed from & 0x01
              crc <<= 1; // changed from right shift
              if (mix) crc ^= 0x31;// changed from 0x8C;
              inbyte <<= 1; // changed from right shift
            }
          }
          if (crc == wh2_packet[4])
          {
            wh2_valid = true;
          }
          else
          {
            wh2_valid = false;
          }
          /*
                Serial.print("| Sensor ID: ");
                Serial.print(Sensor_ID);
                Serial.print(" | humidity: ");
                Serial.print(humidity, DEC);//power
                Serial.print(" | temperature: ");
                Serial.print(temperature / 10.0);
                Serial.print("C | ");
                Serial.println((wh2_valid ? "OK " : "BAD" ));
          */


          if (Sensor_ID == 68 && wh2_valid == true)
          {
            extern char have_data;
            have_data = 1;
            extern float temp;
            temp = temperature / 10.0;
            extern float hum;
            hum = humidity;
          }

          extern std::string my_data;
          my_data = "| Sensor ID: ";
          my_data += to_string(Sensor_ID);
          my_data += " | humidity: ";
          my_data += to_string(humidity);
          my_data += " | temperature: ";
          my_data += to_string(temperature / 10.0);
          my_data += "C | ";
          my_data += (wh2_valid ? "OK " : "BAD" );
          extern char have_data_string;
          have_data_string = 1;


          wh2_accept_flag = false;
        }
        wh2_flags = 0x00;
      }
      //--------------------------------------------------------
    }



    MyCustomSensor() : PollingComponent(100) { }

    void setup() override 
	{
		
		
      Serial.end();//if you are using rx pin for reciever (3)
	  
      attachInterrupt(3, ext_int_1, CHANGE);
	  
	  
    }



    void update() override {
      // This is the actual sensor reading logic.
      extern std::string my_data;
      extern char have_data;
      extern float temp;
      extern float hum;

      if (have_data)
      {
        have_data = 0;

        sensor1->publish_state(temp);
        sensor2->publish_state(hum);
      }

    }
};




class Last_sensor_data : public PollingComponent, public TextSensor {
  public:

    // constructor
    Last_sensor_data() : PollingComponent(100) {}

    void setup() override {
      // This will be called by App.setup()
    }
    void update() override {
      extern std::string my_data;
      extern char have_data_string;
      if (have_data_string == 1)
      {
        publish_state(my_data);
	    have_data_string = 0;
      }

      // This will be called every "update_interval" milliseconds.
      // Publish state

    }
};



Posts: 3

Participants: 2

Read full topic

PIR sensor debounce from strong LED light being turned on/off

$
0
0

@InToSSH wrote:

Hi, I have hacked a cheap LED panel ceiling light from China, added Wemos D1 Mini, relay to turn it on and replaced the stock 230V PIR sensor with HC-SR501.

Problem is that the LEDs are shining from the sides, through a transparent acrylic glass to produce the light and the PIR sensor is in the middle of the glass, so the PIR sensor is hit by the strong light from all sides, which causes the PIR to trigger when there is a change off->on, on->off.

I tried shielding the PIR sensor with black electrical tape from all sides, but it is still not perfect, so I want to add SW “debounce”

I managed to get it somewhat working. But I am using the PIR as a part of home security and also Home Assistent sometimes turns the light on even without PIR (to make it look like somebody is home when we are actually not). This is a problem because as soon as HA turns the light back off, it triggers the PIR sensor, and triggers home security.

This is what I have so far:

globals:
  - id: no_detect
    type: bool
    restore_value: no
    initial_value: 'false'
	
binary_sensor:

  - platform: gpio
    pin: D1
    name: "F Hall Ceiling Light Motion"
    id: motion
    device_class: motion
    on_press:
      then:
        - if:
            condition:
              lambda: 'return !id(no_detect);'
            then:
              - if:
                  condition:
                    or:
                      - binary_sensor.is_off: brightness
                      - switch.is_on: ignore_brightness
                  then:
                    - script.stop: turn_off_lights
                    - if:
                        condition:
                          switch.is_off: night_mode
                        then:
                          - light.turn_on: main_light
                          - light.turn_off: rgb_light
                        else:
                          - light.turn_on: rgb_light
                          - light.turn_off: main_light
                          
        
    on_release:
      then:
        - script.execute: turn_off_lights
              
script:
  - id: turn_off_lights
    then:
      - if:
          condition:
            switch.is_off: always_on
          then:
            - delay: 10s
			- script.execute: motion_debounce
            - light.turn_off: main_light
            - light.turn_off: rgb_light
            
  - id: motion_debounce
    then:
      - globals.set:
          id: no_detect
          value: 'true'
          
      - delay: 5s
      - globals.set:
          id: no_detect
          value: 'false'
          

I was thinking about actually making a template binary_sensor as a pseudo PIR sensor for HA, which would get triggered only after the debounce checks, but this solution seems rather clunky.

I would just somehow want to effectivelly disable the PIR sensor events within 5s of the light being turned on or off, no matter if triggered by HA or PIR sensor.
Can anybody think of a better solution please?
Thanks

Posts: 6

Participants: 2

Read full topic

Viewing all 1486 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>