daniloc / PicoW_HomeAssistant_Starter

Everything you need to get started with your own Intranet of Things, using the high-quality, low-cost Pico W as the backbone.
MIT License
198 stars 20 forks source link

Errors trying to compile #3

Closed pdcq closed 1 year ago

pdcq commented 1 year ago

Trying to compile the project I get the following errors: Compiling .pio/build/pico/lib74c/home-assistant-integration/HAMqtt.cpp.o src/HAIntegration.cpp:15:26: error: no matching function for call to 'HASwitch::HASwitch(const char [4], bool)' 15 | HASwitch led("led", false); | ^

src/HAIntegration.cpp:36:9: error: 'class HASwitch' has no member named 'onStateChanged' 36 | led.onStateChanged(switchHandler); | ^~~~~~ Compiling .pio/build/pico/lib74c/home-assistant-integration/device-types/HABaseDeviceType.cpp.o *** [.pio/build/pico/src/HAIntegration.cpp.o] Error 1

pdcq commented 1 year ago

Setting up an Adruino MEGA with platformIO and Home Assistant worked.

Looking at the difference between both I see that with this implementation for the PicoW the Class HASwitch does not have a member "onStateChanged" while with the Arduino MEGA HASwitch contains the member., using the same library: dawidchyrzynski/home-assistant-integration@^2.0.0

I'm quite new to all this, used to do simple things with the Arduino One and Arduino IDE. I have no clue how to solve it. I started interest in VSCode with PlatformIO because of this project. Now I'm stuck totally unable to understand how to fix this. I followed the exact instructions with a fresh installation on both Windows and Ubuntu platform, so the issue is not related to any configuration on my end (I hope). Many thanks.

pdcq commented 1 year ago

With dawidchyrzynski/home-assistant-integration@^2.0.0 HASwitch was modified between different versions of the library above. onStateChanged is no more, and has been replaced by onCommand. This needs to be modified in HAIntegration.cpp

Also HASwitch led... definition is different. Now it compiles, and I was able to transfer it to the pico w (but manually copying firmware.uf2 MQTT Feedback is not working yet,

So, not all is in it's place on the configuration for this git project. A pity that this isn't fixed (who knows when). Kudos

daniloc commented 1 year ago

Thanks for the heads-up here—changes to that dependency really did foul things up. Confirmed your fix and updated the project.

As to your MQTT issues, couldn't reproduce that locally with a fresh install to a Pico W, though I did see a couple hiccups propagating state between HA and the device, so there may be something else going on with the new code. I know that the rework on arduino-home-assistant was substantial.

I'll look into it more, and feel free to share anything notable from the logs in your MQTT broker, @pdcq