• 0 Posts
  • 40 Comments
Joined 2 years ago
cake
Cake day: June 18th, 2023

help-circle





  • I cant test this, but should it be something like:

    # Example button configuration
    button:
      - platform: template
        name: Livingroom Lazy Mood 1
        id: my_button
    
        # Optional variables:
        icon: "mdi:emoticon-outline"
        on_press:
          - logger.log: "Button 1 pressed"
      - platform: template
        name: Livingroom Lazy Mood 2
        id: my_button2
    
        # Optional variables:
        icon: "mdi:emoticon-outline"
        on_press:
          - logger.log: "Button 2 pressed"
    

    As for the other thing, that might be something you need to write your own driver for? if you need some inspiration, this repo has a driver for mitsubishi heatpumps, which does something similar (read/write to a uart): https://github.com/echavet/MitsubishiCN105ESPHome




  • Depends on the project (and the maintainers), but have you reached out to the developers for assistance?

    Touching a foreign codebase is always difficult, even for professional coders. I have found that it usually is a very hard slog for a few weeks or so, and then it will start to click in place. I think the only real shortcut is to ask for help and see if an existing dev can guide you through it.






  • The esphome config is more like a build script, it builds an esphome binary with the config built in. They are fairly simple yaml files, and there is plenty of doco and examples about. Esphome will generate a basic config for you, and you can modify it to suit.

    So, to start with, you just need to install the esphome addon in HA. From there, you can plug the esphome dev board into the PC you use to access HA (ideally, youll want to use chrome, as it supports flashing the esp device directly), and in the esphome interface click the “New device” button. You choose a name for the device, and then click connect. Esphome UI will then connect to your board, and try to determine what it is, and will setup a basic “failsafe but does nothing” config, and it will flash it to the board.

    From there, you can unplug the board, and subsequent flashes can happen over wifi. Adjust the config and reflash until it works. Home assistant should detect the board when it next boots up and you can add it as a device.

    If you get dev boards, no additional hardware is required, its built into the usb interface. Software wise, you will need to use Chrome for the first setup, as firefox doesnt support WebSerial which is needed gor the first flash.

    If you have any other questions shout out.

    If you want something more “flash, then configure”, tasmota is another option. You flash the device from a webbrowser (https://tasmota.github.io/install), and then next time it boots it starts a wifi network you can connect to, and then you can connect to a web interface and use a gui to configure it and connect it to your HA. Esphome is a little more work upfront, but your configs can be backed up more easily.



  • I second the early return suggestions, but the other thing you should be aware of is that isalpha() is being evaluated twice unnecessarily. If its cheap and not call frequently, not a real big problem, but it is a waste of cycles. If you want to document the else, you could try:

    ...
    }
    else  // isAlpha() == false
    {
    ...
    

    Also, if isAlpha was something that could change between evaluation, such as isTuesday, you are at risk of the first call returning false, and then the second call returning true, which would skip both cases.