Esphomelib - A comprehensive solution for using ESPs with Home Assistant


#247

great work Otto
I would love to use this, I’m always copying and pasting code together to try and combine sensors together and it’s never straight forward and this looks really straight forward to use.

I haven’t been able to get this to work though. My USB is not recognised?

I have tried this several times with different boards (NodeMCU and D1 mini) and done a usb cables swap, I’ve also re-installed esphomeyaml…but I have the same problem everytime?

My computer shows the usb on the port and I can upload via arduino so the ports seem fine.


#248

The esphome addon appears to be running on a different machine judging from the address line. You need to plug in the USB cable to the device that is running esphome, not the device where you’re viewing the dashboard. Alternatively read FAQ for other ways of initial flashing.


#249

That would explain it! Thanks Otto I plugged it in the correct machine and it works… :man_facepalming:


#250

How does the app know which device to upload to when doing OTA updates after the initial flashing?

Does it go completely off of the configured IP address in the yaml file or does it use some other way to know which is the target device?

the reason I’d like to find out is that I would like to “pre-flash” a bunch of devices with a generic install with only the “esphomeyaml” and “wifi” sections configured. Obviously I would give them all unique names but they would be generic names (device_1, device_2, etc). Then later once I decide where the permanent home is going to be for them then I want to be able to upload the specific config for that device with a proper useful name.

So can I then just change the name of the yaml file from, for example, device_1.yaml to kitchen_light.yaml and then ESPHome would know that I want to upload the config to the old device_1 hardware?


#251

It goes entirely off of the IP address configured in the YAML (or hostname if no manual ip is given).

In esphome 1.11.0 you will have an use_address option which will probably achieve what you want: https://beta.esphome.io/components/wifi


#252

thanks. i figured that was the case. or at least something in the ballpark.

time to get flashing!


#253

I just updated to v88.1 and now I’m getting a bunch of this in my log for every ESPHome device:

2019-02-25 16:15:46 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 344, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: sensor.big_room_humidity. Platform esphome does not generate unique IDs
2019-02-25 16:15:46 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 344, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: sensor.big_room_temperature. Platform esphome does not generate unique IDs
2019-02-25 16:15:46 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 344, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: sensor.big_room_sensor_esphome_version. Platform esphome does not generate unique IDs
2019-02-25 16:15:47 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 344, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: sensor.sunroom_temperature. Platform esphome does not generate unique IDs
2019-02-25 16:15:47 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 344, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: sensor.sunroom_humidity. Platform esphome does not generate unique IDs

I just saw another thread where others were getting the same thing.

I’ve gone thru and removed all of the duplicate ESPHome devices on the integrations pag and as soon as I restart HA they all come back along with those errors.

Any ideas?

I hope I didn’t switch from tasmota too quickly…:wink: :smile:


#254

Does everything still work despite the errors?


#255

It seems so…


#256

@OttoWinter, I installed the 64-bit hassio image running on a Pi3+B. I’m just two months into HA so making my share of mistakes and wrong turns along the way.
Question, will your project support 64-bit anytime soon? Mostly curious, planning my next moves which include moving everything to an old Dell Precision laptop I have.
Really looking forward to using this!
K


#257

esphome works fine on a 64 bit ubuntu (ie amd64) machine here.


#258

I believe the issue isn’t the machine being 64 bit, but rather the 64 bit version of hassio.


#259

It works on my 64bit Hass.io on debian (qemux86-64-homeassistant)


#260

@Stoney Are you talking about a hassio addon?


#261

Hi @OttoWinter I was looking for ways to implement speed control / dimming with ESP’s and discovered these. Would it be possible to create a component in ESPhome to drive them? (I don’t have the skills to do so, working on it…)

EDIT: Looking at the Generic Custom Component under ESPhome I guess I could try and use code from here to put something together. Thats if I get some time. I’d really like to get this working with a rotary encoder to adjust the dimming. I think they could prove to be a very cost effective HA compatible dimmer / fan controller.


#262

Yes, I should have specified, 64-bit version of Hass.io.
From the addon page:
" NOTE : Installation on RPis running in 64-bit mode is currently not possible. Please use the 32-bit variant of HassOS instead."


#265

Is there a way to add more light effects to FastLed light?


#266

@INTEL, l Here’s an except out of a YAML file for a project I did with esphome where I defined a number of additional FastLED effects. I had a string of 100 WS2812 LEDs arranged as a stack of rings that looks like this:


Some of the effects are defined like this:

light:
  - platform: fastled_clockless
    chipset: WS2811
    pin: GPIO13
    num_leds: 100
    rgb_order: RGB
    name: "Tower"
    id: tower
    effects:
      - flicker:
      - fastled_rainbow:
      - fastled_color_wipe:
      - fastled_scan:
      - fastled_twinkle:
      - fastled_random_twinkle:
      - fastled_fireworks:
      - fastled_flicker:
      - fastled_lambda:
          name: rings
          update_interval: 100ms
          lambda: |-
            static uint8_t current_ring = 0;
            static uint8_t current_hue = 0;
            auto leds = it.leds();
            fadeToBlackBy(leds, it.size(), 100);
            current_ring = (current_ring + 1) % led_rings;
            for (int i = 0; i < led_ringsize; i++)
                leds[ledoffset(current_ring, i)] = CHSV(current_hue, 255, 200);
            if (current_ring >= led_rings - 1)
                leds[0] = CHSV(current_hue, 255, 255);

            if (current_ring == 0) {
                current_hue += 10;
                if (current_hue > 255)
                    current_hue = 0;
            }

            it.schedule_show();

      - fastled_lambda:
          name: "Red Alert"
          update_interval: 100ms
          lambda: |-
            static uint8_t current_ring = 0;
            fadeToBlackBy(it.leds(), it.size(), 100);
            current_ring = (current_ring + 1) % led_rings;
            for (int i = 0; i < led_ringsize; i++)
                it.leds()[ledoffset(current_ring, i)] = CHSV(0, 255, (128 * current_ring)/(led_rings - 1) + 127);

            if (current_ring >= led_rings - 1)
                it.leds()[0] = CRGB(255,255,0);

            it.schedule_show();

      - fastled_lambda:
          name: bounce
          update_interval: 100ms
          lambda: |-
            static int current_ring = 0;
            static int direction = 1;
            static uint8_t current_hue = 0;
            auto leds = it.leds();
            fadeToBlackBy(leds, it.size(), 100);

            current_ring = (current_ring + direction);
            if (current_ring < 0) {
                current_ring = 0;
                direction = 1;
            }
            if (current_ring >= led_rings) {
                current_ring = led_rings - 1;
                direction = -1;
            }

            for (int i = 0; i < led_ringsize; i++)
                leds[ledoffset(current_ring, i)] = CHSV(current_hue, 255, 200);
            if (current_ring >= led_rings - 1)
                leds[0] = CHSV(current_hue, 255, 255);

            if (current_ring == 0) {
                current_hue += 10;
                if (current_hue > 255)
                    current_hue = 0;
            }

            it.schedule_show();

      - fastled_lambda:
          name: clock
          update_interval: 100ms
          lambda: |-
            // clock
            auto time = id(sntp_time).now();
            uint8_t  seconds = time.second;
            uint8_t  minutes = time.minute;
            uint8_t  hours   = time.hour;
            uint8_t  seconds_tens = seconds / 10;
            uint8_t  minutes_tens = minutes / 10;
            uint8_t  hours_tens   = hours / 10;
            seconds = seconds % 10;
            minutes = minutes % 10;
            hours   = hours % 10;

            static int ticks = 0;
            static uint8_t col_start = 0;

            #define col_hours_tens     (col_start)
            #define col_hours          (col_start +  1)
            #define col_minutes_tens   (col_start +  2)
            #define col_minutes        (col_start +  3)
            #define col_seconds_tens   (col_start +  4)
            #define col_seconds        (col_start +  5)

            const unsigned int hue_hours = HUE_GREEN;
            const unsigned int hue_minutes = HUE_BLUE;
            const unsigned int hue_seconds = HUE_RED;

            // column 0 - tens of hours
            // column 1 - hours
            // column 2 - tens of minutes
            // column 3 - minutes
            // column 4 - tens of seconds
            // column 5 - seconds
            // flash top ring dim red/dim blue by seconds

            //if (++ticks > 150) {    // note update_interval above
            //  ticks = 0;
            //    if (--col_start < 0)
            //        col_start = led_ringsize;
            //}

            auto leds = it.leds();
            fadeToBlackBy(leds, it.size(), 200);

            CRGB flash = (seconds & 1) ? CRGB::Cyan : CRGB::Magenta;
            leds[0] = flash;
            // invert state for other
            flash = ((seconds & 1) == 0) ? CRGB::Cyan : CRGB::Magenta;
            leds[ledoffset(led_rings - 1, col_start + 8)] = flash;

            // const unsigned int led_spacer = 1;
            // const unsigned int led_rings = 9;
            // const unsigned int led_ringsize = 11;
            // int ledoffset(unsigned int ring, unsigned int member)

            for (int i = 0; i < led_rings; i++) {
                leds[ledoffset(i, col_hours_tens)]   = CHSV(hue_hours,   /*sat*/ 255, /*brightness*/ 00);
                leds[ledoffset(i, col_hours)]        = CHSV(hue_hours,   /*sat*/ 150, /*brightness*/ 00);
                leds[ledoffset(i, col_minutes_tens)] = CHSV(hue_minutes, /*sat*/ 255, /*brightness*/ 00);
                leds[ledoffset(i, col_minutes)]      = CHSV(hue_minutes, /*sat*/ 150, /*brightness*/ 00);
                leds[ledoffset(i, col_seconds_tens)] = CHSV(hue_seconds, /*sat*/ 255, /*brightness*/ 00);
                leds[ledoffset(i, col_seconds)]      = CHSV(hue_seconds, /*sat*/ 150, /*brightness*/ 00);
            }

            for (int i = 1; i <= seconds_tens; i++)
                leds[ledoffset(i - 1, col_seconds_tens)] = CHSV(hue_seconds, /*sat*/ 255, /*brightness*/ 250);
            for (int i = 1; i <= seconds; i++)
                leds[ledoffset(i - 1, col_seconds)]      = CHSV(hue_seconds, /*sat*/ 150, /*brightness*/ 250);
            for (int i = 1; i <= minutes_tens; i++)
                leds[ledoffset(i - 1, col_minutes_tens)] = CHSV(hue_minutes, /*sat*/ 255, /*brightness*/ 250);
            for (int i = 1; i <= minutes; i++)
                leds[ledoffset(i - 1, col_minutes)]      = CHSV(hue_minutes, /*sat*/ 150, /*brightness*/ 250);
            for (int i = 1; i <= hours_tens; i++)
                leds[ledoffset(i - 1, col_hours_tens)]   = CHSV(hue_hours,   /*sat*/ 255, /*brightness*/ 250);
            for (int i = 1; i <= hours; i++)
                leds[ledoffset(i - 1, col_hours)]        = CHSV(hue_hours,   /*sat*/ 150, /*brightness*/ 250);

            it.schedule_show();

This might give you an idea of how to add more effects with your own C++ code. You can get into all sorts of creative trouble using lambda in esphome…


#267

Awsome! Thank’s for the code!
I’m also trying to replicate some effects I had in old setup (BRUH light), fire effect to be specific. Is there a way to implement those?
I found some code here, is it possible to ‘‘convert’’ those?


#268

It’s very likely those examples could be adapted to call the FastLED library from inside the esphome environment. The code you include inside the lambda is called repeatedly, similar to how the loop() function in the arduino environment is. The it variable refers to the FastLED object, I believe.

I think one problem that would need to be solved is that those examples you noted use a delay() function in their definition. I’m not sure that’s going to work inside the esphome environment, since you probably can’t block inside the lambda… For instance, the WiFi has be serviced as well as all the other stuff that’s going on. The code in the lambda is called on a periodic basis (which you get to specify), so you might need to re-factor that code into a state machine or something that’s called periodically.

I’m not an expert by any means with the FastLED library (or esphome, for that matter), so I just sort of fumbled around trying stuff. If you’ve questions about it, there’s a discord channel for esphome that could also be helpful; I had some questions answered over there when I was working on my simple project.