visualapproach / WiFi-remote-for-Bestway-Lay-Z-SPA

Hack - ESP8266 as WiFi remote control for Bestway Lay-Z spa Helsinki
GNU General Public License v3.0
297 stars 74 forks source link

Home Assistant and MQTT #342

Closed SchallertDK closed 2 years ago

SchallertDK commented 2 years ago

Hi, I cant get my MQTT Broker to automatic find the Spa module. Everything's seems to work. The spa modul is connected to MQTT: image

And the Home Assistant receive data from the spa module: image

But the broker wont find it? And i cant get the lovelace as showed in your "Build-instructions-Bestway-WiFi-remote.pdf": image

image

What am i missing? 2 peoples has tried to help me, but we cant find the "error"?

chunkysteveo commented 2 years ago

are you on a 4-wire pump? Auto discovery isn't implemented yet on the 4-wire firmware...

SchallertDK commented 2 years ago

Yes i have. How do i so do? :)

chunkysteveo commented 2 years ago

You have to manually add in the sensors at the moment - using the code and help in the repo https://github.com/visualapproach/WiFi-remote-for-Bestway-Lay-Z-SPA/tree/master/Code/Home%20assistant%20config

SchallertDK commented 2 years ago

Thank you, I will try to set it up. But i'm not an expert at this HA yet :)

chunkysteveo commented 2 years ago

It's not too difficult if you follow the readme, and go slowly. Best bet is to just test ONE sensor, such as the bubbles as a switch sensor. If you then see it in HA, and can toggle it, and the bubbles go on/off - you've cracked it(!) carry on with importing the rest of the sensors!

Best of luck!

visualapproach commented 2 years ago

Dev branch version has now autodiscovery for 4 wire pumps. You are welcome to test it.

chunkysteveo commented 2 years ago

Ohh i may test! My efforts worked, but the climate wouldn't import for me.

Will try the new dev branch......

visualapproach commented 2 years ago

Ohh i may test! My efforts worked, but the climate wouldn't import for me.

Will try the new dev branch......

I had some trouble too. Turned out the message was too long for the ESP to handle so don't use long base names.

chunkysteveo commented 2 years ago

Ahhh - i was getting there.... cutting down the packaged worked. Good to know I was on the right track!

chunkysteveo commented 2 years ago

Just added a PR for model NO54154 as it was missing AIR in the config @visualapproach.

visualapproach commented 2 years ago

Alright, will handle it when !AFK

chunkysteveo commented 2 years ago

Auto discovery worked really well - but the God Mode switch didn't import into HA?

SchallertDK commented 2 years ago

My HA went in "Safe Mode" after trying adding new "text"

I made a file named "layzspa.yaml" into the folder "package" and pasted everything from the layzspa.yaml file at github + removed the # at the 2 areas where it only was for the 4-wired pump.

In the configuration.yaml i added: image

In the automations.yaml i added what was in the "automations.yaml" file at github

About the two helpers i need to make, i cant find any helpers who can take the infos from the github file? image

image

To get out of "safe mode" at the HA i had to delete "homeassistant: packages: !include_dir_named packages" from the configuration.yaml

So i'm back to start again and dont know what i have done wrong

chunkysteveo commented 2 years ago

If you can download the "Development" branch of this project - HA Autodiscover is now in place and does work for me - adds in all the required sensors (apart from god mode switch?). Maybe try the development branch - treat it like a new project - so you will need to set your model number etc and upload again. But then at least HA will/should work.

Alternatively you can just add in the sensors and switches and climate in the configuration.yaml file in their appropriate places.

I've not used packages in HA, so can't advise. But the helpers - one is a Number helper, and the other is a "Toggle" helper.

SchallertDK commented 2 years ago

I had now downloaded the development zip file, opened like a new project, change the parameters so it is matching my pump and ip. Build image file, uploade to the spa module. everything with "succes". But i stil dont se any activity at the MQTT in HA. The Spa module is connected with MQTT an no fails there. About this GOD MODE you write about, where do i manually enable that? I cant find it in the PlatformIO file?

chunkysteveo commented 2 years ago

Hmm, not sure if it's not working for you? If you go to Integrations, MQTT it should be there as a new device with entities?

The god mode switch is the "Take Control" switch which allows us to control the 4-wire pumps. It was/is called god mode in the code in parts(!).

SchallertDK commented 2 years ago

Ok, the Take Control bottom is at the Spa "website" - So i think it is ok? The MQTT is still not reacting for any new device? image

I have restartet the HA and the Spa ESP 3 times, with no respons.

When i'm typing # at the configuration in the MQTT it shows the communication to the spa module: image

chunkysteveo commented 2 years ago

Is discovery enabled in Mosquito? If you click on re-configure MQTT and check it is? and the topic is homeassistant/status ? image

SchallertDK commented 2 years ago

Yes it is: image

chunkysteveo commented 2 years ago

hmm, i'm not 100% sure what the issue is, sorry?

You can still try to add the switches and sensors manually into HA using configuration.yaml

chunkysteveo commented 2 years ago

Try adding the below in configuration.yamlwhere you have switch: (you can't have more than one switch: declaration, so look for it and add below it, or copy and paste all of the below if there is no switch:)

switch:
  - platform: mqtt
    name: "Hot Tub Bubbles"
    icon: "mdi:chart-bubble"
    state_topic: "layzspa/message"
    command_topic: "layzspa/command"
    value_template: "{{ value_json.AIR }}"
    payload_on: '{"CMD":2,"VALUE":1,"XTIME":0,"INTERVAL":0}'
    payload_off: '{"CMD":2,"VALUE":0,"XTIME":0,"INTERVAL":0}'
    state_on: 1
    state_off: 0
    availability_topic: "layzspa/Status"
    payload_available: "Alive"
    payload_not_available: "Dead"      
SchallertDK commented 2 years ago

This text i have to replace in the configuration.yaml, where the "switch" for air bubbles is right? In yoour switch it is named hot tub bubbles

chunkysteveo commented 2 years ago

Yeah, mine is called Hot Tub Bubbles, you can call it what you like.

SchallertDK commented 2 years ago

Right now my HA is down, and i cant reach it. I tried to make those 2 helpers, and then it went down.

Next question is: the 2 areas with "#" , i have to delete the # at both areas right?

When i try to make that "layzspa.yaml" file in the "package" folder, then i have to add this in the configuration.yaml, and remove the "#", right? : image

But when i do this, the HA says it is wrong and, when i delete it, the HA is happy again. Right now i have it all in the configuration.yaml - But it is right?

chunkysteveo commented 2 years ago

I'm not sure on using the packages way - mine was all just added to the main configuration.yaml file in one go. Editing yaml is tricky to get the indents and format right.

SchallertDK commented 2 years ago

Okay, then i will do the same. What about this: ? Did you add this in the configuration.yaml in the bottom after all the other stuff? image

chunkysteveo commented 2 years ago

No, I have them added individually - my HA is a large setup that's been worked on for years now. I would recommend reading up or watching some tutorials on how to add custom switches and sensors to yaml.

SchallertDK commented 2 years ago

Thank you for your help today, i will watch som tutorials :)

visualapproach commented 2 years ago

I fixed a minor thing in HA config for the 4w now. Best result is when you do it in this order: 1 - Update ESP 2 - delete the old device from HA: image 3 - restart ESP 4 - look at the device in HA again. Refresh page with F5 if it's not populated yet.

visualapproach commented 2 years ago

And for now, use max 14 chars in base topic.

SchallertDK commented 2 years ago

I couldn't remove the old device as you shows in the screendump, because i never got the chance to find it. I have uploaded the last version to the ESP I have manually removed all text regarding the spa in the configuration.yaml Restartet the ESP and refreshing (F5) the HA multiply times, but nothing is popping up?

What are the "max 14 chars in base topic"?

visualapproach commented 2 years ago

image

SchallertDK commented 2 years ago

is the Client ID and Base Topic: layzspa2 - in the instructions is the name "layzspa" I have try setting the Telemetry Interval from 600 to 5, but no changes

visualapproach commented 2 years ago

I don't understand what you're asking. Base topic is whatever you type in the box. And you should not type more than 14 characters for now. Changing the telemetry interval will, well, change the interval between mqtt messages

SchallertDK commented 2 years ago

My spa module says it is connected with MQTT My HA gets data from the spa module But i cant make lovelace or get the lovelace as shown in the instructions pages. When i manually import node-red flow, and set up af lovelace with that, there is no communication between lovelace and spa module. But it shows in node-red that it is connected and running: image

visualapproach commented 2 years ago

You don't need node red to get a dashboard. Disable that flow, I think it just messes things up unless you have a good reason to use it. Then restart HA then restart ESP. Go to devices in the configure page.

SchallertDK commented 2 years ago

Still no sign of new device in the MQTT :( image

visualapproach commented 2 years ago

Judging from your picture you are looking at the wrong place. Click on DEVICES in the top menu

SchallertDK commented 2 years ago

This one? - And how do i do then? :) image

visualapproach commented 2 years ago

No! Go back to devices and find layzspa device instead of the mqtt broker

SchallertDK commented 2 years ago

There is nothing called layzspa, nothing at al even with the word "spa" (?)

visualapproach commented 2 years ago

You need v3.4.0 of the firmware

SchallertDK commented 2 years ago

Now you lost me again :) Firmware to the esp (spa module?)

chunkysteveo commented 2 years ago

Yes - he has released a new release which includes HA auto discovery for 4 wire as standard.

SchallertDK commented 2 years ago

But i downloaded the last development file yesterday (21.07.2022) and uploaded it. image

SchallertDK commented 2 years ago

But the firmware at the spa module says: image

chunkysteveo commented 2 years ago

It will be very similar, if not the same as a dev branch. I am just testing the new release now.

SchallertDK commented 2 years ago

Is there any where else i can check that it is the right version? I tried to search in the Visual Studio Code for "firmware" but couldn't find any "version" number

visualapproach commented 2 years ago

But the firmware at the spa module says:

image

Meaning you didn't upload it properly because then it would say 2022-07-21

chunkysteveo commented 2 years ago

The latest release is the latest, which includes HA Auto discovery. I have just downloaded it, set it up on my pump and it's connection to MQTT, HA, and pulled in as a device with all sensors. The firmware/code works, but there is an issue with your setup somewhere?

Have you set the model number and PCB version in model.h file. Then upload and set MQTT etc. IT should then work with autodisovery...?