Giter Site home page Giter Site logo

esphome / esphome Goto Github PK

View Code? Open in Web Editor NEW
7.7K 167.0 3.2K 22.31 MB

ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.

Home Page: https://esphome.io/

License: Other

Python 29.93% Dockerfile 0.06% Shell 0.09% C++ 69.76% C 0.15% Groovy 0.01%
home-automation iot esp8266 esp32 home-assistant mqtt python platformio yaml hacktoberfest

esphome's Introduction

esphome's People

Contributors

agners avatar anonym-tsk avatar ayufan avatar balloob avatar bdraco avatar buxtronix avatar carlosgs avatar clydebarrow avatar dependabot[bot] avatar dudanov avatar edwardtfn avatar fabian-schmidt avatar frenck avatar glmnet avatar guillempages avatar heman avatar jesserockz avatar kahrendt avatar kbx81 avatar kroimon avatar martgras avatar mmakaay avatar nielsnl68 avatar ottowinter avatar oxan avatar paulmonigatti avatar puuu avatar robomagus avatar senexcrenshaw avatar ssieb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esphome's Issues

Hassio addon not working

I have create 2 yaml files for my sonoff modules but when I press compile or validate buttons I get a terminated process message and nothing is done. I have not attached the module yet to flash because I want to migrate from Tasmota to this.

My yaml file looks like this:

esphomeyaml:
  name: Sonoff2
  platform: ESP8266
  board: esp01_1m
  board_flash_mode: dout

wifi:
  ssid: 'XXXXXXXXX'
  password: 'XXXXXXXXXXX'

mqtt:
  broker: 'XXXX.XXXXXXXXXXXX.XXX'
  username: ''
  password: ''

# Enable logging
logger:

ota:
  password: 'XXXXXX'

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "Sonoff Basic Button"
  - platform: status
    name: "Sonoff Basic Status"

switch:
  - platform: gpio
    name: "Sonoff Basic Relay"
    pin: GPIO12

output:
  - platform: esp8266_pwm
    id: basic_green_led
    pin: GPIO13
    inverted: True

light:
  - platform: monochromatic
    name: "Sonoff Basic Green LED"
    output: basic_green_led

Integrate RCSwitch

Hey!

I would like to integrate the RCSwitch library into esphomeyaml, to use its TriState functionality for 433mhz based wall plugs.

I HAVE seen the built in functionality for 433mhz of esphomeyaml but it wasnt able to satisfy me, as the RAW type of the data is quite hard to handle compared to basic TriState encoding. And the RCSwitch lib is working like a charm for over two years now and the wheel shouldn't need to be reinvented.

So I just thought I should be able to reimplement the RemoteTransmitterSwitch using it, but this seems to be harder than thought due to a total lack of documentation. I was unable to find anything about custom output components or at least a reference implementation of an output component.

I imagine the result as follows:

#File: home.yaml

#[...]

switch:
  - platform: rc_switch
    name: "bedroom_lamp"
    on_tristate: "F0FF00FFFF0F" #example TriState value to turn on
    off_tristate: "F0FF00FFFFF0" #example TriState value to turn on

rc_switch:
  pin: D7
  protocol: 1 #optional: RCSwitch.setProtocol()
  pulse_length: 305 #optional: RCSwitch.setPulseLength()
  

So what would be the right way of doing this?

change icon

how can i change the icon, i try:

`light:

  • platform: rgb
    name: "Luz de Escritorio"
    icon: "mdi: track-light"
    red: output_component1
    green: output_component2
    blue: output_component3`

but it doesnt work, it cant validate

Extensibility

At the moment, esphomeyaml is not very extensible: once you need some functionality that isn't shipped by default, you have to dive into the c++ code - which in itself is fine - but the problem is that this doesn't play well with the generated code: as far as I can see, there's no way to register a custom component. Creating a custom component instance in the cpp file and referencing from YAML isn't possible either because it doesn't find that ID.

For example, I'm trying to make a light that flashes when turned on. This is pretty easy to achieve in c++ code, but turns out to be very hard to integrate with esphomeyaml. I'd want to make a custom output component that turns on and off repeatedly, as long it's enabled; pretty simple. However, I'd also like to use this as the output for a light component, configuring this in the YAML file; this doesn't seem to be possible.

I see 2 possible solutions (maybe to be used together):

  1. Only log a warning, instead of raising an error, when an ID isn't found. This would allow creating a custom component instance in the cpp code, and referencing this from the YAML file
  2. Allow registering custom components to be used in YAML, just like the built-in lights, outputs, sensors etc.

Web server makes ESP crash on Sonoff basic !

Just using latest version of tool. I have done following configuration file for my Sonoff basic:

esphomeyaml:
  name: sdb_light
  platform: ESP8266
  board: esp01_1m
  board_flash_mode: dout

wifi:
  ssid: 'myssid'
  password: 'mywifipass'

mqtt:
  broker: '192.168.1.8'
  username: 'mymqttlogin'
  password: 'mymqttpass'

# Enable logging
logger:

ota:

switch:
  - platform: gpio
    name: "SDB Lumière"
    pin: GPIO12

Configuration likes that works perfectly ! If I add the web component, as soon as I play one or two times with the on/off button in web interface the ESP crashes !

Vincèn

Custom variables in lambdas

Is there any way to declare and initialize variables that can be used by the lambda? It'd be easy enough to drop into the c++ code to do this, I'm wondering if there's a way to do it from pure YAML.

Use case

I have a very simple garage door opener that works as follows:

  • When closed, will open on a single button press
  • When open, will close on two presses 1 second apart
  • When moving, will stop on a single button press
  • When stopped, only the following two reversal motions are available:
    • If previously closing, will open on a single press
    • If previously opening, will close on two presses 1 second apart

I have a relay wired up to the button contacts, and have simple close and open scripts in Home Assistant that trigger relay toggles 1 second apart - once to open or twice to close.

I'd like to convert this over to the cover model. However, I need a small state machine to determine how to open or close the door given its previous direction of motion. This could probably be accomplished with a lambda and a variable to store which way it was last moving.

KeyError: 'inverted' while building

I am getting this stacktrace while compiling the code below using the Docker container:

  File "/usr/local/bin/esphomeyaml", line 11, in <module>
    load_entry_point('esphomeyaml', 'console_scripts', 'esphomeyaml')()
  File "/usr/src/app/esphomeyaml/__main__.py", line 287, in main
    exit_code = write_cpp(config)
  File "/usr/src/app/esphomeyaml/__main__.py", line 125, in write_cpp
    get_variable(None)
  File "/usr/src/app/esphomeyaml/helpers.py", line 325, in get_variable
    func(config)
  File "/usr/src/app/esphomeyaml/components/binary_sensor/gpio.py", line 16, in to_code
    rhs = App.make_gpio_binary_sensor(config[CONF_NAME], exp_gpio_input_pin(config[CONF_PIN]))
  File "/usr/src/app/esphomeyaml/helpers.py", line 428, in exp_gpio_input_pin
    return exp_gpio_pin_(GPIOInputPin, conf, u'INPUT')
  File "/usr/src/app/esphomeyaml/helpers.py", line 407, in exp_gpio_pin_
    conf[CONF_INVERTED])
KeyError: 'inverted'
pcf8574:
  - id: pcf8574_hub
    address: 0x20

binary_sensor:
  - platform: gpio
    pin:
      pcf8574: pcf8574_hub
      number: 0
      mode: INPUT
    name: Pin0
    inverted: False

Build fails with and without the inverted parameter.

multiwifi

Hi,
A feature request: What do you think about multiwifi - There is a ESP Lib where you can configure several wifi ssids and the strongest will be selected (or based on some priority). I use this to connect espnodemcus at home and at your makerspace.

Feature request: Specify custom target IPs for OTA update

Following some best practices, i have separated my IoT Devices into a separate VLAN, which also has a separate SSID in my Wifi access point. I don't want to impute writing malicious code to you, @OttoWinter , but it was easier for me to put the ESPs into this VLAN as well, for firewall ruling and similar actions.

To cut a long story short: Another VLAN is another broadcast domain, so the resolving of .local during OTA process is failing. The ESP host itself is pingable via its IP address and even via internal DNS, since i specified an entry for it. So it would be great to have an option in the YAML file to specify a specific IP address or hostname for OTA, so that esphomeyaml isn't sending the invitation to .local but merely to the specified IP address.

If one does not explicitly specify this option, trying .local would be a good fallback option.

On a somehow related side note: Is port 13564 for the OTA server to listen on a fixed value? I need to specify a firewall rule to enable talkback from the IoT VLAN to the VLAN where my desktop PC resides.

Upgrade to latest version?

Checking to see how to update to the current release with both cli install and HASSIO addon?

With CLI when I rerun the pip install it does not update to the current release.

remote_recever won't compile : error: 'esp_err_to_name' was not declared in this scope

Hi,

I'm trying to add the remote_receiver to sniff some 433mhz remote control signals with a nodemcu-32s.
But, as soon as I add the remove_receiver component, esphomeyaml won't build.

Here is the errors I got:

<command-line>:0:16: warning: ISO C++11 requires whitespace after the macro name
In file included from .piolibdeps/esphomelib/src/esphomelib/remote/remote_protocol.cpp:10:0:
.piolibdeps/esphomelib/src/esphomelib/remote/remote_protocol.cpp: In member function 'virtual void esphomelib::remote::RemoteReceiverComponent::setup()':
.piolibdeps/esphomelib/src/esphomelib/remote/remote_protocol.cpp:155:77: error: 'esp_err_to_name' was not declared in this scope
ESP_LOGE(TAG, "Configuring RMT remote failed: %s", esp_err_to_name(error));
^
.piolibdeps/esphomelib/src/esphomelib/log.h:124:130: note: in definition of macro 'esph_log_e'
#define esph_log_e(tag, format, ...) esp_log_printf_(ESPHOMELIB_LOG_LEVEL_ERROR, tag, ESPHOMELIB_LOG_FORMAT(tag, E, format), ##__VA_ARGS__)
^
.piolibdeps/esphomelib/src/esphomelib/remote/remote_protocol.cpp:155:5: note: in expansion of macro 'ESP_LOGE'
ESP_LOGE(TAG, "Configuring RMT remote failed: %s", esp_err_to_name(error));
^
.piolibdeps/esphomelib/src/esphomelib/remote/remote_protocol.cpp:162:76: error: 'esp_err_to_name' was not declared in this scope
ESP_LOGE(TAG, "Installing RMT driver failed: %s", esp_err_to_name(error));
^
.piolibdeps/esphomelib/src/esphomelib/log.h:124:130: note: in definition of macro 'esph_log_e'
#define esph_log_e(tag, format, ...) esp_log_printf_(ESPHOMELIB_LOG_LEVEL_ERROR, tag, ESPHOMELIB_LOG_FORMAT(tag, E, format), ##__VA_ARGS__)
^
.piolibdeps/esphomelib/src/esphomelib/remote/remote_protocol.cpp:162:5: note: in expansion of macro 'ESP_LOGE'
ESP_LOGE(TAG, "Installing RMT driver failed: %s", esp_err_to_name(error));
^
.piolibdeps/esphomelib/src/esphomelib/remote/remote_protocol.cpp:168:81: error: 'esp_err_to_name' was not declared in this scope
ESP_LOGE(TAG, "Getting RMT ringbuf handle failed: %s", esp_err_to_name(error));
^
.piolibdeps/esphomelib/src/esphomelib/log.h:124:130: note: in definition of macro 'esph_log_e'
#define esph_log_e(tag, format, ...) esp_log_printf_(ESPHOMELIB_LOG_LEVEL_ERROR, tag, ESPHOMELIB_LOG_FORMAT(tag, E, format), ##__VA_ARGS__)
^
.piolibdeps/esphomelib/src/esphomelib/remote/remote_protocol.cpp:168:5: note: in expansion of macro 'ESP_LOGE'
ESP_LOGE(TAG, "Getting RMT ringbuf handle failed: %s", esp_err_to_name(error));
^
.piolibdeps/esphomelib/src/esphomelib/remote/remote_protocol.cpp:174:81: error: 'esp_err_to_name' was not declared in this scope
ESP_LOGE(TAG, "Starting RMT for receiving failed: %s", esp_err_to_name(error));
^
.piolibdeps/esphomelib/src/esphomelib/log.h:124:130: note: in definition of macro 'esph_log_e'
#define esph_log_e(tag, format, ...) esp_log_printf_(ESPHOMELIB_LOG_LEVEL_ERROR, tag, ESPHOMELIB_LOG_FORMAT(tag, E, format), ##__VA_ARGS__)
^
.piolibdeps/esphomelib/src/esphomelib/remote/remote_protocol.cpp:174:5: note: in expansion of macro 'ESP_LOGE'
ESP_LOGE(TAG, "Starting RMT for receiving failed: %s", esp_err_to_name(error));
^
*** [.pioenvs/remoteliving/libf8d/esphomelib/esphomelib/remote/remote_protocol.cpp.o] Error 1

And here is my configuration file:

esphomeyaml:
  name: remoteliving
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: '<redacted>'
  password: <redacted>'

mqtt:
  broker: '<redacted>'
  username: '<redacted>'
  password: '<redacted>'

logger:

ota:
remote_receiver:
  pin: GPIO32
  dump: all

I already tried:

  • Uninstall/Reinstall esphomeyaml with pip
  • Delete this node folder (./remoteliving)

What else could I try? Thanks for your help!
(And this greeeaaat tool!)

Addon doesn't work when behind ssl nginx

I'm using bestlibre nginx to map ports to sub domains and have proper certificates. Unfortunately it seems the ws connection when compiling is not secure or not taking into account that it's running on secure when trying to connect back.

I get a warning in chrome and then nothing happens when compiling. Is there a way to get around this?

I was able to get it to work with a local ip behind nginx. I guess it's not such a good idea to expose it through nginx as it doesn't have authentication.

Switch state in conditions ?

Hi

Do you plan to be able to trigger some automations on some input.switch ? I have sonoff devices and I'd like to program them so one of the LEDs on it reflects the state of the relay ;)

Thanks

Bme280 error reporting after upgrade from 1.6.2 to 1.7

After i upgraded to 1.7 my bme280 starts to report incorrect value, ad ex:
[sensor.bme280:193]: Got temperature=0.7°C pressure=258601.6hPa humidity=14.3%

reverting to 1.6.2 resolve the issue:

[sensor.bme280:193]: Got temperature=24.7°C pressure=1012.0 hPa humidity=64.3%

[Feature Request] Input validation

When a user enters a device name with upper-case characters, it fails to validate or compile. But since the plugin doesn't appear to have a way to go back and edit the file, they will have to go to a configuration editor or jump over to command line to fix it.

The failure could be avoided in the first place if ESPhomeYAML did a first pass simple validation on the input field in initial config, or else did an automatic conversion to lower-case.

Support for BMP280

The BMP280 is the "cheaper/simpler" version of the BME280 which is already supported.

Thanks in advance.

Main stream hardware

Hi,
I'm very interested in your project. I'm wondering if esphomeyaml can be used with common hardware like sonoffS20 plug or arilux al-lc03 led driver ?

I'm an intensive user of home Assistant (and sometimes a contributor) and I'm looking for an easy way to convert and update my hardware. For now I'm using the tasmota firmware.

error during compilation when Installing toolchain-xtensa32

Trying to set my first sensor with esphomeyaml, I'm creating a dallas component base yaml file.

When trying to compile, I have the following error:

PackageManager: Installing toolchain-xtensa32 @ ~2.50200.0
Error: Could not find a version that satisfies the requirement '~2.50200.0' for your system 'linux_armv7l'

yaml file:

esphomeyaml:
  name: capteur_piscine
  platform: ESP32
  board: lolin32

wifi:
  ssid: '####'
  password: '#####'

mqtt:
  broker: '192.168.1.28'
  username: '####'
  password: '####'

# Enable logging
logger:

ota:
  password: '#######'

# Example configuration entry
dallas:
  - id: dallas_hub1
    pin: 4

# Individual sensors
sensor:
  - platform: dallas
    dallas_id: "dallas_hub1"
    address: 0x28FF88A9C117049C
    resolution: 10
    name: "Température Piscine"

Hardware/Software:

Feature Request: make build output path configurable

It would be nice to have the build output path configurable, so one can put all build output folders in a seperate folder, to streamline folder structure. this would also help ignoring the build output folders in gitignore files.

current situation:

  • smart-home
    |- livingroom.yaml
    |- livingroom

would like to change it to:

  • smart-home
    |- livingroom.yaml
    |- build
    |-- livingroom

I think these would need another config property and changes to these method:
https://github.com/OttoWinter/esphomeyaml/blob/a04438e92434fcc472ebfce5a1d923630ec012c6/esphomeyaml/__main__.py#L27

Template Cover example does not work

The example specifies both lambda and optimistic, which is not allowed:

  cover.template:
    - Invalid config for [cover.template]: Cannot specify more than one of lambda, optimistic.

Additionally, the generated c++ code (if I remove optimistic) does not seem to be valid:

binary_sensor:
  - platform: gpio
    id: garage_door
    device_class: garage_door
    name: Garage Door
    pin:
      number: 12
      inverted: False
      mode: INPUT_PULLUP

switch:
  - platform: gpio
    id: garage_door_switch
    name: Garage Door Switch
    pin: 27

cover:
  - platform: template
    id: garage_door_opener
    name: "Garage Door Opener"
    lambda: >-
      if (id(garage_door).value) {
        return cover::COVER_CLOSED;
      } else {
        return cover::COVER_OPEN;
      }
    open_action:
      - switch.turn_on:
          id: garage_door_switch
      - delay: 1s
      - switch.turn_off:
          id: garage_door_switch
    close_action:
      - switch.turn_on:
          id: garage_door_switch
      - delay: 1s
      - switch.turn_off:
          id: garage_door_switch
      - delay: 1s
      - switch.turn_on:
          id: garage_door_switch
      - delay: 1s
      - switch.turn_off:
          id: garage_door_switch
    stop_action:
      - switch.turn_on:
          id: garage_door_switch
      - delay: 1s
      - switch.turn_off:
          id: garage_door_switch

results in:

Compiling .pioenvs/garage/src/main.cpp.o
src/main.cpp: In function 'void setup()':
src/main.cpp:24:26: error: expected unqualified-id before '->' token
template_cover.template->set_state_lambda([=]() {
^
*** [.pioenvs/garage/src/main.cpp.o] Error 1

from the following code:

  auto template_cover = App.make_template_cover("Garage Door Opener");
  auto gpio_switch = App.make_gpio_switch("Garage Door Switch", 27);
  auto *garage_door_switch = gpio_switch.switch_;
  auto gpio_binary_sensor = App.make_gpio_binary_sensor("Garage Door", GPIOInputPin(12, INPUT_PULLUP, false));
  auto *garage_door = gpio_binary_sensor.gpio;
  garage_door->set_device_class("garage_door");
  template_cover.template->set_state_lambda([=]() {
      if (garage_door->value) {
        return cover::COVER_CLOSED;
      } else {
        return cover::COVER_OPEN;
      }
  });

Bug in OTA update process !

Using the OTA update with command line argument to indicate specific IP of my ESP, it uploads successfully the firmware file in OTA but then turns in serial mode for logs instead of doing it through IP (don't know if it's possible) or then close the process and that's it ;)

12:53:25 [DEBUG]: Options: {'esp_ip': '192.168.1.152', 'host_port': 53445, 'image': '.pioenvs/led_strips/firmware.bin', 'host_ip': '0.0.0.0', 'auth': '', 'esp_port': 8266, 'spiffs': False, 'debug': True, 'progress': True}
12:53:25 [INFO]: Starting on 0.0.0.0:53445
12:53:25 [INFO]: Upload size: 384880
Sending invitation to 192.168.1.152
12:53:25 [INFO]: Waiting for device...
Uploading: [============================================================] 100% Done...

12:53:38 [INFO]: Waiting for result...
12:53:38 [INFO]: Result: OK
================================================================ [SUCCESS] Took 15.16 seconds ================================================================
INFO [esphomeyaml.__main__] Successfully uploaded program.
INFO [esphomeyaml.__main__] Starting log output from 192.168.1.152 with baud rate 115200
Traceback (most recent call last):
  File "/usr/local/bin/esphomeyaml", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/__main__.py", line 463, in main
    return run_esphomeyaml(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/__main__.py", line 453, in run_esphomeyaml
    return POST_CONFIG_ACTIONS[args.command](args, config)
  File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/__main__.py", line 325, in command_run
    return show_logs(config, args, port, escape=args.escape)
  File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/__main__.py", line 218, in show_logs
    run_miniterm(config, port, escape=escape)
  File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/__main__.py", line 103, in run_miniterm
    with serial.Serial(port, baudrate=baud_rate) as ser:
  File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 240, in __init__
    self.open()
  File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port 192.168.1.152: [Errno 2] No such file or directory: '192.168.1.152'

[Huge] [Suggestion / Feature Request] Configuration Templating

Hey folks!
esphomeyaml is a great way of managing the functionality of a single device, but quickly fails when trying to manage a bigger fleet of devices.

TL;DR

Split the configuration into templates and instances, generate the final code for each instance

The Problem

As long as the number of ESP's stays quite low, it's no problem to duplicate the .yaml for every single ESP.
But as I plan to deploy in massive scale (30+ hardware equal devices), this is no option because of the following reasons:

  • Most of these duplicated files would contain the same .. actually only the service names are going to change.
  • As soon as I need to change anything on all nodes of the fleet, I would need to edit ALL files, which is not reasonable in any way.

The Solution

To solve this, I suggest a templating system for the configuration files. The idea is stolen from proved templating systems used in web-development. (e.g. Handlebars, mustache, etc.)

The idea is the following:
The configurations gets split into a template, and into instances. The template describes, how all devices together are and the instances contain specific data about a single device.

Instead of creating a single .yaml-file for the configuration, it gets a folder. This could look as follows:


Configuration of hardware type "wifi_socket":
Folder name: .../home/wifi_socket/. where home is the root of all hardware types, wifi_socket an example hardware type

Contents:

  • wifi_socket.yaml: Basically a regular esphomeyaml-config, the same way as it is right now, but on steroides: Everything that is device specific, gets replaced by {{ placeholder }}. For example:
# kitchensocket1.yaml
esphomeyaml:
  name: "Kitchen Socket #1"

gets:

# wifi_socket.yaml
esphomeyaml:
  name: "{{ name }}"

At this point, the template is a general state, describing the whole fleet at once. To create the code for the specific instances, there are seperate .yaml-files:

/wifi_socket.yaml
/instances/
          /kitchensocket1.yaml
          /kitchensocket2.yaml
          /tvsocket.yaml
          /... .yaml

Each of these files contain simple key-value mappings, of the placeholders of the template:

# kitchensocket1.yaml
name: "Kitchen Socket #1"
# (...)

Finally, for every instance, the specific values get merged into the final .yaml-file in memory and compiled to the code folder, the same way, esphomeyaml already does, just into it's own folder:

/wifi_socket.yaml
/instances/
          /kitchensocket1.yaml
          /kitchensocket2.yaml
          /tvsocket.yaml
/dist
          /kitchensocket1/
                         /lib
                         /src
                         /platformio.ini
          /kitchensocket2/
          /tvsocket/

Great outline .. but why is this useful?

This system has several advantages:

  1. Most important: Hardware related stuff can be changed in a single file for ALL boards of the same type, while the specific board gets its specific data in it's dedicated configuration
  2. Now one can edit all boards in a single file, reflecting the changes into every instance with no need to do 30+ equal changes.

Final words

I really hope at least one person understands my idea lol .. or at least read until this point.
The implementation could be put into the esphomeyaml python app, or wrapped around it using a new application, or esphomeyaml could even be changed into an API, providing the ability to script on top of it.

Proposals for a logo

Hi!

Inspired by this Twitter thread I have done some rough sketches for what I think would make a nice logo, or, rather a starting point. They are pretty straightforward in their metaphor (a stylised ESP8266 as mounted on the NodeMCU in varying degrees of abstraction + a house) but I think the simplicity works rather well.
nodemcu_amica_bot_02

I really liked @OttoWinter's idea to work with the chip's antenna, as it is quite a distinct feature, however I am also drawn to no.1 visual simplicity. Maybe someone will be inspired to a eureka moment by one of these.

Note that I kept the name esphomelib for now, as @OttoWinter is still thinking about the name.

esphomelib logo proposal-01
esphomelib logo proposal.pdf

Cheers

[Feature Request] Remember MQTT Broker Details and Wifi Details

Have an option in the web UI to remember both your MQTT Broker details and the details for the Wifi, I think this could get pretty repetitive if you have a whole bunch of esp devices to set up. Perhaps even if we were able to give them a "default value" that might be suitable? Thanks

"no known conversion" error with IR raw transmitter

I want to make an IR transmitter with the following yaml code:

switch:
  - platform: ir_transmitter
    name: "ON/OFF"          
    raw:          
      carrier_frequency: 38kHz
      data:                   
        - 1300
        - -300
        - 1300
        - -300
        - 300 
        - -1300
        - 300  
        - -1300
        - 300  

It's translated into the following C code by esphomeyaml:

  auto *switch__switch = App.register_component(switch__irtransmittercomponent->create_transmitter("ON/OFF", switch_::ir::SendData::from_raw({
          1300,
          -300,
          1300,
          -300,
          300,
          -1300,
          300,
          -1300,
          300,
  }, 38000)));

But I get this error at compile time:

src/main.cpp: In function 'void setup()':
src/main.cpp:28:11: error: no matching function for call to 'esphomelib::switch_::ir::SendData::from_raw(, int)'
}, 38000)));
^
src/main.cpp:28:11: note: candidate is:
In file included from .piolibdeps/esphomelib/src/esphomelib/application.h:63:0,
from src/main.cpp:2:
.piolibdeps/esphomelib/src/esphomelib/switch_/ir_transmitter_component.h:108:19: note: static esphomelib::switch_::ir::SendData esphomelib::switch_::ir::SendData::from_raw(std::vector&, uint32_t)
static SendData from_raw(std::vector &raw_data, uint32_t carrier_frequency);
^
.piolibdeps/esphomelib/src/esphomelib/switch_/ir_transmitter_component.h:108:19: note:   no known conversion for argument 1 from '' to 'std::vector&'
*** [.pioenvs/device1/src/main.cpp.o] Error 1

Deep Sleep settings: can't use run_duration and run_cycles in the same time

According to documentation we can use both parameters:

To use deep_sleep first specify how long the node should be active, i.e. how long it should check sensor values and report them, using the run_duration and run_cycles options. If you use both in your configuration, any time either one of them is finished, the node will go into deep sleep mode.

In my case:

esphomeyaml:
  name: capteur_piscine
  platform: ESP32
  board: lolin32

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

mqtt:
  broker: '192.168.1.28'
  username: !secret mqtt_username
  password: !secret mqtt_password

# Enable logging
logger:

ota:
  password: !secret ota_password

# Example configuration entry
dallas:
  - id: dallas_hub1
    pin: 4
    update_interval: 1s

# Individual sensors
sensor:
  - platform: dallas
    dallas_id: "dallas_hub1"
    address: 0x9C0417C1A988FF28
    name: "Température Piscine"
    icon: "mdi:oil-temperature"
    expire_after: "1:02"
    availability:

deep_sleep:
  run_duration: 20s
  run_cycles: 15
  sleep_duration: 1h

Seems to not work, the node go to deep sleep before the first cycle.

JSON string in MQTT Birth and LWT Payloads

Hi,

I’m trying to use a JSON string in Birth and LWT payloads but getting an error regarding
Mqtt: - Invalid config for [mqtt]: string value cannot be dictionary or list.

Is there some way of getting this to work?

BME280

Using a BME280 with the following configuration is not able to retrieve the humidity.

i2c:
  sda: 21
  scl: 22
  scan: False

sensor:
  - platform: bme280
    temperature:
      name: "Temperature"
      oversampling: 16x
    pressure:
      name: "Pressure"
    humidity:
      name: "Humidity"
    address: 0x76
    update_interval: 15s

Debug:

[C][sensor.bme280:095]: Setting up BME280...
[C][sensor.bme280:096]:     Address: 0x76
[C][sensor.bme280:126]:     Temperature Oversampling: 16x
[C][sensor.bme280:127]:     Pressure Oversampling: 16x
[C][sensor.bme280:128]:     Humidity Oversampling: 16x
[C][sensor.bme280:129]:     IIR Filter: OFF
[...]
[D][sensor.bme280:177]: Got temperature=26.0°C pressure=952.6hPa humidity=0.0
[D][sensor.mqtt:038]: 'Temperature': Pushing out value 25.980000 with accuracy 1
[D][sensor.mqtt:038]: 'Pressure': Pushing out value 952.551331 with accuracy 1
[D][sensor.mqtt:038]: 'Humidity': Pushing out value 0.000000 with accuracy 1

Sorry, I have only one of those sensors at hand at the moment.

Missing tornado dependency for dashboard

Just updated to 1.6.0 and tried to start the dashboard. Got a stack trace instead:

Traceback (most recent call last):
  File "/home/media/django/bin/esphomeyaml", line 11, in <module>
    sys.exit(main())
  File "/home/media/django/local/lib/python2.7/site-packages/esphomeyaml/__main__.py", line 437, in main
    return run_esphomeyaml(sys.argv)
  File "/home/media/django/local/lib/python2.7/site-packages/esphomeyaml/__main__.py", line 414, in run_esphomeyaml
    return PRE_CONFIG_ACTIONS[args.command](args)
  File "/home/media/django/local/lib/python2.7/site-packages/esphomeyaml/__main__.py", line 318, in command_dashboard
    from esphomeyaml.dashboard import dashboard
  File "/home/media/django/local/lib/python2.7/site-packages/esphomeyaml/dashboard/dashboard.py", line 30, in <module>
    class EsphomeyamlCommandWebSocket(tornado.websocket.WebSocketHandler):
NameError: name 'tornado' is not defined

Works fine after installing tornado.

Support ESP8285

I realized that some Arilux devices run on ESP8285 (like my Arilux AL-LC03) and not on ESP8266. Is there any support on the roadmap ?

Program fails to run

IM running Home Assistant on Raspberry PI, and Ive carried out the install, using the command
pip install esphomeyaml

When i run esphomeyaml livingroom.yaml wizard I recieve a notification that esphomeyaml cannot be found.

I know this is probably a basic issue, but its not one i know how to resolve.

Easy control of RGB LED controler ?

Hi

I'm using these Wifi LED strips controler based on ESP:
espleds1
It's fairly basic and use one GPIO for each color (R/G/B). Is it me or it's a little overcomplicated for basic control as I need to declare each color output like that:

output:
  - platform: gpio
    pin: 25
    id: 'color_red'

and then:

light:
  - platform: rgb
    name: "Living Room Lights"
    red: color_red
    green: color_green
    blue: color_blue

Isn't it possible to directly declare GPIO in light platform ?

Thanks

Vincèn

hassio addon 1.6.2 plataformio name resolution

Using hassio addon 1.6.2 after run the wizard for nodemmcu esp8266 12e i get the following error
esphomeyaml:
name: termoacumulador
platform: ESP8266
board: esp12e

[API] ConnectionError: HTTPConnectionPool(host='api.platformio.org', port=80): Max retries exceeded with url: /v2/lib/search?query=name%3A%22ArduinoOTA%22 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6a96761150>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)) (incremented retry: max=5, total=5)

Mqtt Availability option error

Hi, i've installed new 1.7 release but when i configure availability in mqtt as documented:

mqtt:
  broker: 'xxx.xxx.xxx.xxx'
  username: 'xxxx'
  password: 'xxxxx'
  availability: 

when i compile it returns me the following error:

Failed config
mqtt:
- Invalid config for [mqtt]: [availability] is an invalid option for [mqtt]. Check: mqtt->availability.

iBeacon Support

It would be super awesome if esphomeyaml could announce itself as an iBeacon via BLE.
This would allow iOS (Owntracks, mostly) to track positions in greater detail

Set IP address in web interface for upload

The name.local doesn't work for me unless I add my sensors to the hosts file of the docker container. It would be nice to specify the IP address of the device as a fallback when that doesn't work.

Run code without wifi

First off thank you for your amazing work in creating this.

Secondly I have a slight issue/feature recommendation. I am using an esp8266 to control the led drivers powering my reef lights over mqtt using HA, but the issue is the wifi signal there is pretty weak. So if the Esp loses wifi it turns off the lights within seconds.

So is it possible to just keep the last mqtt value until it gets wifi instead of turning the leds off.

Also was not entirely sure if to post this here or esphomelib.

DHT sensor GPIO pin is not properly set

I have some problems with setting up a DHT22 sensor. After making sure that the hardware is fine, it is definitely a software issue. I dug into some files, and noticed the following. This is the sensor definition in the YAML:

sensor:
  - platform: dht
    pin: D4
    model: DHT22
    temperature:
      name: "Schlafzimmer Temperatur"
    humidity:
      name: "Schlafzimmer Luftfeuchtigkeit"
    update_interval: 15s

The pin ist set to D4, as this is the official D1 mini DHT22 shield. Unfortunately, after compiling the firmware, i only get NaN values, so i looked in the generated code. The DHT22 sensor is set up like following:

  auto dht_sensor = App.make_dht_sensor("Schlafzimmer Temperatur", "Schlafzimmer Luftfeuchtigkeit", 0, 15000);
  dht_sensor.dht->set_dht_model(DHT::DHT22);

If i interpret esphomelib's API documentation correctly, the third argument of make_dht_sensor should be the sensor's pin - which is set to 0, contrary to the YAML's definition of D4. The documentation of esphomeyaml looks like that one has to specify D4 and not only 4. However, i have noticed that, if i specify 4 as the pin, it is correctly parsed and written in the source file - but, of course, the ESP fails to communicate with the DHT due to the wrong pin.

So, either i have not fully understood the config file format (especially after taking a look at pins.py) or there is a bug...?

Wishlist: 'generate' command

I am running ephomeyaml in docker and upload using native platformio:

docker run --rm -v "`pwd`":/config -it ottowinter/esphomeyaml livingroom.yaml compile
platformio run -d livingroom -t upload

The first step compiles everything while the second compiles it again. It would be nice to have a 'generate' command that only generates the cpp code in the first step.

error with DHT

Hi
I get the following error every time with the dht.

[21:37:51][C][sensor.mqtt:025]: Setting up MQTT Sensor '2'...
[21:37:51][C][sensor.mqtt:027]: Expire After: 675s
Traceback (most recent call last):
File "/usr/local/bin/esphomeyaml", line 11, in
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/main.py", line 458, in main
return run_esphomeyaml(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/main.py", line 448, in run_esphomeyaml
return POST_CONFIG_ACTIONS[args.command](args, config)
File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/main.py", line 320, in command_run
return show_logs(config, args, port, escape=args.escape)
File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/main.py", line 216, in show_logs
escape=escape)
File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/mqtt.py", line 65, in show_logs
return initialize(config, [topic], on_message, username, password, client_id)
File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/mqtt.py", line 36, in initialize
client.loop_forever()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1481, in loop_forever
rc = self.loop(timeout, max_packets)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1003, in loop
rc = self.loop_read(max_packets)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1284, in loop_read
rc = self._packet_read()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1849, in _packet_read
rc = self._packet_handle()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2305, in _packet_handle
return self._handle_publish()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2500, in _handle_publish
self._handle_on_message(message)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2647, in _handle_on_message
self.on_message(self, self._userdata, message)
File "/usr/local/lib/python2.7/dist-packages/esphomeyaml/mqtt.py", line 63, in on_message
print(time + message)
File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 40, in write
self.__convertor.write(text)
File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 141, in write
self.write_and_convert(text)
File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 68: ordinal not in range(128)

RFE: Support for momentary switches

Thanks for the great library! I think this is awesome.

Anyways, I see that the current suggested way for doing momentary switches (the "garage door opener" example) has Home Assistant doing the momentary logic. It might be nicer if the momentary logic was implemented on the ESP itself.

My thoughts:

  1. The timing would be more accurate
  2. Less likely for an output to be "stuck on" if HA crashes or wifi / mqtt goes down.
  3. Can also be reliably "restored" if the ESP crashes and reboots.

In my case, I have an ESP wired up to my apartments door buzzer. That thing is definitely not rated for continuous duty - I really don't want to ever have it stuck on! I currently have some custom code on my ESP for this, but I'd love to migrate.

If you think this is a good idea, I'm happy to implement this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.