jshank / bwalink

Automate your Balboa Spa! A docker container with socat and ccutrer/balboa_worldwide_app that supports a remote serial to IP device or host running ser2net, socat or ESPEasy serial server
30 stars 6 forks source link

docker run environment variables not set #4

Closed jamienich closed 2 years ago

jamienich commented 2 years ago

Hi @jshank,

I tried this on Docker WSL2 on a WIndows 10 desktop.

The docker run command works, however it would appear the mqtt environment variable isn't setting. It's attempting to connect the mqtt client to 10.1.10.2 port 1883 instead of my env variable 172.30.32.x (real number removed).

I tried quoting the environment variables a few ways, but nothing seemed to work.

Powershell output window below:

_docker run --rm ghcr.io/jshank/bwalink:latest -e 'MQTT_URI=mqtt://homeassistantusername:reallylongpassword@172.30.32.x' -e 'BRIDGE_IP=192.168.0.x'
docker : 2021/12/27 04:30:42 socat[7] E connect(7, AF=2 10.1.12.127:8899, 16): Connection refused
At line:1 char:1
+ docker run --rm ghcr.io/jshank/bwalink:latest -e 'MQTT_URI=mqtt://hom ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (2021/12/27 04:3...nection refused:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

/usr/local/bundle/gems/mqtt-ccutrer-1.0.1/lib/mqtt/client.rb:484:in `initialize': Connection refused - connect(2) for "10.1.10.2" port 1883 (Errno::ECONNREFUSED)
    from /usr/local/bundle/gems/mqtt-ccutrer-1.0.1/lib/mqtt/client.rb:484:in `new'
    from /usr/local/bundle/gems/mqtt-ccutrer-1.0.1/lib/mqtt/client.rb:484:in `connect_internal'
    from /usr/local/bundle/gems/mqtt-ccutrer-1.0.1/lib/mqtt/client.rb:240:in `connect'
    from /usr/local/bundle/gems/homie-mqtt-1.6.0/lib/mqtt/homie/device.rb:34:in `initialize'
    from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/exe/bwa_mqtt_bridge:28:in `new'
    from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/exe/bwa_mqtt_bridge:28:in `initialize'
    from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/exe/bwa_mqtt_bridge:401:in `new'
    from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/exe/bwa_mqtt_bridge:401:in `<top (required)>'
    from /usr/local/bundle/bin/bwa_mqtt_bridge:23:in `load'
    from /usr/local/bundle/bin/bwa_mqtt_bridge:23:in `<main>'_

Any help appreciated, thanks.

jamienich commented 2 years ago

I pulled the github code, edited docker-compose.yaml, hard coded MQTT & BRIDGE_IP with my variables. Will likely change my TZ as well.

doker-compose.yaml

      MQTT_URI: mqtt://homeassistant:queephe6quiZuogh0shee1ieGh6uJ4jeaB4zai2Onubah7uute0ivahT2loowu0h@172.30.32.1
      BRIDGE_IP: 192.168.0.101
      TZ: America/Los_Angeles 

Then I cwd to the github code and ran docker-compose.exe up bwalink

bwalink  | /usr/local/bundle/gems/mqtt-ccutrer-1.0.1/lib/mqtt/client.rb:484:in `initialize': Connection refused - connect(2) for "172.30.32.1" port 1883 (Errno::ECONNREFUSED)

So I had to change the internal Mosquitto IP address to my Raspberry Pi IP address and then it worked, I assume. I ran docker-compose.exe up bwalink and ta dah! Attaching to bwalink bwalink | W, Balboa MQTT Bridge running (version 2.0.5)

Everything was discovered in homeassistant and it appears the spa accepts commands but the bwalink doesn't always publish the states back to homeassistant. For example when the spa is set to rest/ready mode the entity doesn't update but the actual spa itself will update and the controls for the spa are all working.

jshank commented 2 years ago

Appreciate the follow-up @jamienich. I've always used docker-compose since it's tough to get the proper command line escaping with a straight up docker run command. The image defaults are set with my own MQTT_URI and BRIDGE_IP for lack of better examples. It does look like setting the environment variables in your docker-compose.yaml file is properly overriding the defaults so we're good there.

Can you tell me a little more about your stack setup? Is your MQTT broker (Mosquitto?) running on Docker on the RPi? It also sounds like you solved the Docker networking issue by pointing at the docker hosts IP address for your MQTT broker. You can use the internal IP of the docker container but both the bwalink and MQTT container must share the same docker network.

bwalink doesn't always publish the states back to homeassistant

There are a few stops along the line from your spa to Home Assistant, let's see where it's losing the data.

tub -> RS-485 adapter -> balboa_worldwide_app -> MQTT Broker -> Home Assistant

Obviously we don't want to go digging around in the tub so let's start with balboa_worldwide_app and then the MQTT Broker.

  1. Edit your docker environment variables and set LOG_LEVEL: DEBUG
  2. Restart the container docker-compose up -d
  3. View the logs and try changing the ready/rest mode docker-compose logs -f

Feel free to put the relevant log output here. You should see some communication between the tub and balboa_worldwide_app which balboa_worldwide_app then sends to the MQTT broker.

If that is working, we can take a look at the broker and see what it's getting.

  1. Install the mosquitto client files sudo apt-get install mosquitto-clients
  2. Subscribe to the homie topics balboa_worldwide_app publishes to. mosquitto_sub -v -t homie/# -h 172.30.32.1 -p 1883 -u homeassistant -P queephe6quiZuogh0shee1ieGh6uJ4jeaB4zai2Onubah7uute0ivahT2loowu0h

You should see all of the tub state changes being published to MQTT. If we're good to here, the only part left would be where Home Assistant is looking for updates to ready/rest. If you've used multiple versions of BWALink, it might be worthwhile shutting down bwalink and then deleting the BWA Link device from Home Assistant. The next time you start up BWALink, it will recreate the device properly.

jamienich commented 2 years ago

Ah yes good ole escaping, might want to say always use docker-compose.sh in the docs. Otherwise lazy people like me will try docker run and set the variables and invariably they'll always fail.

Yes Mosquitto Broker, it's the Home Assistant integration version. I'm on the latest version.

I believe it's running on a Docker within the Home Assistant, I've installed it using the Home Assistant web portal. This is what's in the default logs.

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] mosquitto.sh: executing... 
[08:27:47] INFO: Certificates found: SSL is available
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] nginx.sh: executing... 
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[08:27:48] INFO: Starting NGINX for authentication handling...
[08:27:48] INFO: Starting mosquitto MQTT broker...
1640726868: mosquitto version 1.6.12 starting
1640726868: |-- *** auth-plug: startup
[08:27:49] INFO: Successfully send discovery information to Home Assistant.
[08:27:50] INFO: Successfully send service information to the Supervisor.
1640726868: Config loaded from /etc/mosquitto/mosquitto.conf.
1640726868: Loading plugin: /usr/share/mosquitto/auth-plug.so
1640726868:  ├── Username/password checking enabled.
1640726868:  ├── TLS-PSK checking enabled.
1640726868:  └── Extended authentication not enabled.
1640726868: Opening ipv4 listen socket on port 1883.
1640726868: Opening ipv6 listen socket on port 1883.
1640726868: Opening websockets listen socket on port 1884.
1640726868: Opening ipv4 listen socket on port 8883.
1640726868: Opening ipv6 listen socket on port 8883.
1640726868: Opening websockets listen socket on port 8884.
1640726868: Warning: Mosquitto should not be run as root/administrator.
1640726868: mosquitto version 1.6.12 running
1640726868: New connection from 127.0.0.1 on port 1883.
1640726868: Socket error on client <unknown>, disconnecting.
1640726884: New connection from 172.30.32.1 on port 1883.
1640726884: New client connected from 172.30.32.1 as 5RtQG8fNg04yBYKvcNsHNf (p2, c1, k60, u'homeassistant').

And this command runs with output

[core-ssh ~]$ mosquitto_sub -v -t homie/# -h 172.30.32.1 -p 1883 -u homeassistant -P
queephe6quiZuogh0shee1ieGh6uJ4jeaB4zai2Onubah7uute0ivahT2loowu0h                                                                             
homie/bwa/spa/hold false
homie/bwa/spa/hold/$name Hold                                                                                                               homie/bwa/spa/hold/$datatype boolean                                                        
homie/bwa/spa/hold/$settable true                                                           
homie/bwa/spa/heating-mode rest                                                             
homie/bwa/spa/heating-mode/$name Heating Mode                                               
homie/bwa/spa/heating-mode/$datatype enum                                                   
homie/bwa/spa/heating-mode/$format ready,rest,ready_in_rest                                 
homie/bwa/spa/heating-mode/$settable true                                                   
homie/bwa/spa/temperature-scale celsius                                                     
homie/bwa/spa/temperature-scale/$name Temperature Scale                                                                                      homie/bwa/spa/temperature-scale/$datatype enum                                                                                               homie/bwa/spa/temperature-scale/$format fahrenheit,celsius                                  
homie/bwa/spa/temperature-scale/$settable true                                              
homie/bwa/spa/twenty-four-hour-time true                                                    
homie/bwa/spa/twenty-four-hour-time/$name 24 Hour Time                                      
homie/bwa/spa/twenty-four-hour-time/$datatype boolean                                       
homie/bwa/spa/twenty-four-hour-time/$settable true                                          
homie/bwa/spa/temperature-range high                                                        
homie/bwa/spa/temperature-range/$name Temperature Range                                     
homie/bwa/spa/temperature-range/$datatype enum                                              
homie/bwa/spa/temperature-range/$format high,low                                            
homie/bwa/spa/temperature-range/$settable true                                              
homie/bwa/spa/target-temperature 40.0                                                       
homie/bwa/spa/target-temperature/$name Target Water Temperature                             
homie/bwa/spa/target-temperature/$datatype float                                            
homie/bwa/spa/target-temperature/$format 10:40                                              
homie/bwa/spa/target-temperature/$settable true                                             
homie/bwa/spa/target-temperature/$unit °C                                                   
homie/bwa/spa/pump1 0                                                                       
homie/bwa/spa/pump1/$name Pump 1                                                            
homie/bwa/spa/pump1/$datatype integer                                                       
homie/bwa/spa/pump1/$format 0:2                                                             
homie/bwa/spa/pump1/$settable true                                                          
homie/bwa/spa/pump2 0                                                                       
homie/bwa/spa/pump2/$name Pump 2                                                            
homie/bwa/spa/pump2/$datatype integer                                                       
homie/bwa/spa/pump2/$format 0:2                                                             
homie/bwa/spa/pump2/$settable true                                                          
homie/bwa/spa/pump3 0                                                                       
homie/bwa/spa/pump3/$name Pump 3                                                            
homie/bwa/spa/pump3/$datatype integer                                                       
homie/bwa/spa/pump3/$format 0:2                                                             
homie/bwa/spa/pump3/$settable true                                                          
homie/bwa/spa/light1 false                                                                  
homie/bwa/spa/light1/$name Lights                                                           
homie/bwa/spa/light1/$datatype boolean                                                      
homie/bwa/spa/light1/$settable true                                                         
homie/bwa/spa/$name Hot Tub                                                                 
homie/bwa/spa/$type BP2100G1                                                                
homie/bwa/spa/$properties hold,priming,heating-mode,temperature-scale,twenty-four-hour-time,heating,temperature-range,current-temperature,target-temperature,circulation-pump,pump1,pump2,pump3,light1                                   
homie/bwa/spa/priming false                                                                 
homie/bwa/spa/priming/$name Priming                            
homie/bwa/spa/priming/$datatype boolean
homie/bwa/spa/heating false                               
homie/bwa/spa/heating/$name Heating
homie/bwa/spa/heating/$datatype boolean
homie/bwa/spa/current-temperature 38.0
homie/bwa/spa/current-temperature/$name Current Water Temperature
homie/bwa/spa/current-temperature/$datatype float
homie/bwa/spa/current-temperature/$format 0:42
homie/bwa/spa/current-temperature/$unit °C
homie/bwa/spa/circulation-pump false
homie/bwa/spa/circulation-pump/$name Circulation Pump Running
homie/bwa/spa/circulation-pump/$datatype boolean
homie/bwa/filter-cycle1/start-hour 12
homie/bwa/filter-cycle1/start-hour/$name Start Hour
homie/bwa/filter-cycle1/start-hour/$datatype integer
homie/bwa/filter-cycle1/start-hour/$format 0:23
homie/bwa/filter-cycle1/start-hour/$settable true
homie/bwa/filter-cycle1/start-hour/$unit hours
homie/bwa/filter-cycle1/start-minute 0
homie/bwa/filter-cycle1/start-minute/$name Start Minute
homie/bwa/filter-cycle1/start-minute/$datatype integer
homie/bwa/filter-cycle1/start-minute/$format 0:59
homie/bwa/filter-cycle1/start-minute/$settable true
homie/bwa/filter-cycle1/start-minute/$unit minutes
homie/bwa/filter-cycle1/duration 152
homie/bwa/filter-cycle1/duration/$name Duration
homie/bwa/filter-cycle1/duration/$datatype integer
homie/bwa/filter-cycle1/duration/$format 0:1439
homie/bwa/filter-cycle1/duration/$settable true
homie/bwa/filter-cycle1/duration/$unit minutes
homie/bwa/filter-cycle1/$name Filter Cycle 1
homie/bwa/filter-cycle1/$type Filter Cycle
homie/bwa/filter-cycle1/$properties running,start-hour,start-minute,duration
homie/bwa/filter-cycle1/running false
homie/bwa/filter-cycle1/running/$name Running
homie/bwa/filter-cycle1/running/$datatype boolean
homie/bwa/filter-cycle2/start-hour 15
homie/bwa/filter-cycle2/start-hour/$name Start Hour
homie/bwa/filter-cycle2/start-hour/$datatype integer
homie/bwa/filter-cycle2/start-hour/$format 0:23
homie/bwa/filter-cycle2/start-hour/$settable true
homie/bwa/filter-cycle2/start-hour/$unit hours
homie/bwa/filter-cycle2/start-minute 30
homie/bwa/filter-cycle2/start-minute/$name Start Minute
homie/bwa/filter-cycle2/start-minute/$datatype integer
homie/bwa/filter-cycle2/start-minute/$format 0:59
homie/bwa/filter-cycle2/start-minute/$settable true
homie/bwa/filter-cycle2/start-minute/$unit minutes
homie/bwa/filter-cycle2/duration 60
homie/bwa/filter-cycle2/duration/$name Duration
homie/bwa/filter-cycle2/duration/$datatype integer
homie/bwa/filter-cycle2/duration/$format 0:1439
homie/bwa/filter-cycle2/duration/$settable true
homie/bwa/filter-cycle2/duration/$unit minutes
homie/bwa/filter-cycle2/enabled true
homie/bwa/filter-cycle2/enabled/$name Enabled
homie/bwa/filter-cycle2/enabled/$datatype boolean
homie/bwa/filter-cycle2/enabled/$settable true
homie/bwa/filter-cycle2/$name Filter Cycle 2
homie/bwa/filter-cycle2/$type Filter Cycle
homie/bwa/filter-cycle2/$properties running,start-hour,start-minute,duration,enabled
homie/bwa/filter-cycle2/running false
homie/bwa/filter-cycle2/running/$name Running
homie/bwa/filter-cycle2/running/$datatype boolean
homie/bwa/$homie 4.0.0
homie/bwa/$name BWA Link
homie/bwa/$nodes spa,filter-cycle1,filter-cycle2
homie/bwa/$state ready

To monitor the MQTT broker I've subscribed to the topic homie/bwa/spa/heating-mode

Message 427 received on homie/bwa/spa/heating-mode at 8:33 AM:
rest
QoS: 0 - Retain: true
Message 426 received on homie/bwa/spa/heating-mode at 8:33 AM:
rest
QoS: 0 - Retain: true
Message 425 received on homie/bwa/$state at 8:32 AM:
ready
QoS: 0 - Retain: true
Message 424 received on homie/bwa/$state at 8:32 AM:
ready
QoS: 0 - Retain: true

I can see it's in 'Rest' state which is correct. Then I go into Devices & BWALink, I set the state to 'Ready' and the following occurs:

Message 433 received on homie/bwa/spa/heatingmode/set at 8:35 AM:
rest
QoS: 0 - Retain: false
Message 432 received on homie/bwa/spa/heatingmode/set at 8:35 AM:
unavailable
QoS: 0 - Retain: false
Message 431 received on homie/bwa/$state at 8:35 AM:
ready
QoS: 1 - Retain: false
Message 430 received on homie/bwa/$state at 8:35 AM:
init
QoS: 1 - Retain: false
Message 429 received on homie/bwa/$state at 8:35 AM:
lost
QoS: 1 - Retain: false
Message 428 received on homie/bwa/spa/heating-mode/set at 8:34 AM:
ready
QoS: 0 - Retain: false

It would appear the MQTT broker has set the state to 'ready' and then a message has been received as 'rest'. So I checked the Home Assistant>Devices>BWA Link>Heating Mode which shows 'rest' I checked the SPA control panel which now shows 'rest' but it's heating.

That's slightly confusing. Next I tried to set the temp to 35 on the spa using the Home Assistant>Devices>BWA Link>Hot Tub Target Water Temp The Home Assistant>Devices>BWA Link>Hot Tub Target Water Temp now shows 35 The SPA control panel which now shows 40 (it did not change to 35), rest, heating.

Message 439 received on homie/bwa/spa/heatingmode/set at 8:42 AM: rest QoS: 0 - Retain: false Message 438 received on homie/bwa/$state at 8:42 AM: ready QoS: 1 - Retain: false Message 437 received on homie/bwa/spa/heatingmode/set at 8:42 AM: unavailable QoS: 0 - Retain: false Message 436 received on homie/bwa/$state at 8:42 AM: init QoS: 1 - Retain: false Message 435 received on homie/bwa/$state at 8:42 AM: lost QoS: 1 - Retain: false Message 434 received on homie/bwa/spa/target-temperature/set at 8:42 AM: 35 QoS: 0 - Retain: false

It looks like more debug is required as you suggest. Also I added the mosquitto accesscontrollist file recently, as I thought maybe homeassistant isn't getting the updates. But it looks like the BWA link is not always passing the temp to the spa and sometimes the spa is doing some strange things which to me suggests something is not quite right with the spa protocol communications in BWALink.

Sorry for the garbled note/thoughts, will try get the proper debugging next time.

jamienich commented 2 years ago

As a personal note, I find it a little disturbing the spa heats in rest mode outside of filter cycles. I've monitored the power consumption at night and found if the current temp < set temp the spa wakes up every x (6-7) hours and heats for about half an hour. So setting the target water temp < current water temp & heating mode in rest and not setting the filter cycles at night is required to stop the spa from consuming night time power.

jamienich commented 2 years ago

Can you tell me a little more about your stack setup?

My Raspberry Pi is been installed with a vanilla Home Assistant OS base image, so Home Assistant OS is it's own Linux Operating System. It's not a downstream distribution of Debian like Ubuntu is. That means I don't know how to install Ruby on Home Assistant OS and haven't found a guide using Google.

I can however root into the Home Assistant OS and perform commands like docker-compose.sh which is installed. There is no apt, no dpkb (debian package manager) and the shell is ash (also known as sh in Ubuntu). So I'm a little green on the Home Assistant OS and Docker but I presume as it's using the Linux kernel, Rugby could be compiled & installed on it, but it might require Home Assistant OS compiling. I might end up leaving it on the PC or setting up another Raspberry Pi with Ubuntu installed on it. Though someone (maybe me) getting working on a vanilla Home Assistant OS might be a good contribution to the community.

I normally develop on Ubuntu server and use Linux Containers (like Docker but it's operating system as opposed to application isolation.

It also sounds like you solved the Docker networking issue by pointing at the docker hosts IP address for your MQTT broker. You can use the internal IP of the docker container but both the bwalink and MQTT container must share the same docker network.

I checked the Home Assistant OS Host iptables and it automatically port forwards all the MQTT ports to the MQTT broker IP address. So from a networking perspective it would appear to bwalink that the MQTT device is the Home Assistant Host and they are both on the same network. Therefore the bwalink and MQTT container being on different networks is okay, a lot of the Internet works like this. And it does appear the MQTT is sending commands to bwalink which are in turn being sent to the spa.

I'm not entirely sure what's happening the bwalink logs but that could be an avenue as well. It appears it crashed and automatically resumed with the a heating mode change


Attaching to bwalink
bwalink  | W, Balboa MQTT Bridge running (version 2.0.5)
bwalink  | /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/lib/bwa/client.rb:254:in `heating_mode=': heating_mode must be :ready or :rest (ArgumentError)
bwalink  |  from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/exe/bwa_mqtt_bridge:169:in `block (2 levels) in publish_basic_attributes'
bwalink  |  from /usr/local/bundle/gems/homie-mqtt-1.6.0/lib/mqtt/homie/property.rb:171:in `set'
bwalink  |  from /usr/local/bundle/gems/homie-mqtt-1.6.0/lib/mqtt/homie/device.rb:116:in `block (3 levels) in publish'
bwalink  |  from /usr/local/bundle/gems/mqtt-ccutrer-1.0.1/lib/mqtt/client.rb:458:in `block in get'
bwalink  |  from /usr/local/bundle/gems/mqtt-ccutrer-1.0.1/lib/mqtt/client.rb:444:in `loop'
bwalink  |  from /usr/local/bundle/gems/mqtt-ccutrer-1.0.1/lib/mqtt/client.rb:444:in `get'
bwalink  |  from /usr/local/bundle/gems/homie-mqtt-1.6.0/lib/mqtt/homie/device.rb:105:in `block (2 levels) in publish'
bwalink  | /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/lib/bwa/client.rb:68:in `readpartial': end of file reached (EOFError)
bwalink  |  from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/lib/bwa/client.rb:68:in `block in poll'
bwalink  |  from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/lib/bwa/client.rb:61:in `loop'
bwalink  |  from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/lib/bwa/client.rb:61:in `poll'
bwalink  |  from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/exe/bwa_mqtt_bridge:59:in `block in initialize'
bwalink  |  from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/exe/bwa_mqtt_bridge:58:in `loop'
bwalink  |  from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/exe/bwa_mqtt_bridge:58:in `initialize'
bwalink  |  from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/exe/bwa_mqtt_bridge:401:in `new'
bwalink  |  from /usr/local/bundle/gems/balboa_worldwide_app-2.0.5/exe/bwa_mqtt_bridge:401:in `<top (required)>'
bwalink  |  from /usr/local/bundle/bin/bwa_mqtt_bridge:23:in `load'
bwalink  |  from /usr/local/bundle/bin/bwa_mqtt_bridge:23:in `<main>'
bwalink exited with code 1
bwalink  | W, Balboa MQTT Bridge running (version 2.0.5)

Also I'm guessing the control states in the Home Assistant BWA Link might not update from the SPA as they are controls as opposed to sensors. Am I right in saying the bwalink device in Home Assistant will only show information returned from the spa in the sensor section? The 'controls' will always be set back to defaults?

jamienich commented 2 years ago

Another avenue we're investigating is how bwalink reads and publishes the messages to homeassistant as the MQTT appears to be receiving the messages and the automations may need to be updated in the latest version of homeassistant.

I'm told the Entity Id names have changed for instance from "input.bwa_link_hot_tub_heating_mode" to "select.bwa_link_hot_tub_heating_mode" that might require a change in the homeassistant bwalink device automations. I'll update you with more information when we figure things out; (my sister is also reviewing the homeassistant config).

jamienich commented 2 years ago

Okay, so I'm now trying the following in the docker.yaml

      TZ: Australia/Sydney 
      LOG_LEVEL: DEBUG # Any of FATAL, ERROR, WARN, INFO or DEBUG

docker-compose up -d bwalink

Thinking the timezone might be important for the bwalink if the application is comparing times with the spa. Because the spa time is set to a local time which is Sydney for me, unless it all works in GMT.

Will post the log output from the Docker container later today.

jamienich commented 2 years ago

I'm sending commands from the homeassistant device bwalink and the pumps work, the temperature doesn't set and the logs are full of time differences, hmmm

Upgrade

Sign in

bwalink
ghcr.io/jshank/bwalink:latest
RUNNING

I,   to spa: #<BWA::Messages::ConfigurationRequest>

D, discarding invalid data prior to message 7e

D, wrote: 7e 05 0a bf 04 77 7e

D,  read: 7e 0d 0a bf 23 0c 00 02 20 8f 1e 01 00 c1 7e

D, from spa: #<BWA::Messages::FilterCycles cycle1 2:32@12:00 cycle2(enabled) 1:00@15:30>

D,  read: 7e 1a 0a bf 24 64 e1 24 00 42 50 32 31 30 30 47 31 01 eb ce 9f d8 03 0a 12 00 c3 7e

D, from spa: #<BWA::Messages::ControlConfiguration BP2100G1 V36.0>

D,  read: 7e 0b 0a bf 2e 2a 00 01 50 00 00 84 7e

D, from spa: #<BWA::Messages::ControlConfiguration2 pumps=[2, 2, 2, 0, 0, 0] lights=[true, false] circulation_pump aux=[false, false]>

W, Balboa MQTT Bridge running (version 2.0.5)

I, Spa time 14:05, actually 09:10; correcting difference of 295 min

I,   to spa: #<BWA::Messages::SetTime 09:10>

D, wrote: 7e 07 0a bf 21 89 0a 0d 7e

I,   to spa: #<BWA::Messages::SetTargetTemperature 80°>

D, wrote: 7e 06 0a bf 20 50 a5 7e

I, Spa time 14:05, actually 09:10; correcting difference of 295 min

I,   to spa: #<BWA::Messages::SetTime 09:10>

D, wrote: 7e 07 0a bf 21 89 0a 0d 7e

D,  read: 7e 0d 0a bf 23 0c 00 02 20 8f 1e 01 00 c1 7e

D, from spa: #<BWA::Messages::FilterCycles cycle1 2:32@12:00 cycle2(enabled) 1:00@15:30>

I, Spa time 14:06, actually 09:10; correcting difference of 296 min

I,   to spa: #<BWA::Messages::SetTime 09:10>

D, wrote: 7e 07 0a bf 21 89 0a 0d 7e

I, Spa time 14:06, actually 09:10; correcting difference of 296 min

I,   to spa: #<BWA::Messages::SetTime 09:10>

D, wrote: 7e 07 0a bf 21 89 0a 0d 7e

I, Spa time 14:06, actually 09:10; correcting difference of 296 min

I,   to spa: #<BWA::Messages::SetTime 09:10>

D, wrote: 7e 07 0a bf 21 89 0a 0d 7e

I, Spa time 14:06, actually 09:10; correcting difference of 296 min

I,   to spa: #<BWA::Messages::SetTime 09:10>

D, wrote: 7e 07 0a bf 21 89 0a 0d 7e

I, Spa time 14:06, actually 09:11; correcting difference of 295 min

I,   to spa: #<BWA::Messages::SetTime 09:11>

D, wrote: 7e 07 0a bf 21 89 0b 0a 7e

I, Spa time 14:06, actually 09:11; correcting difference of 295 min

I,   to spa: #<BWA::Messages::SetTime 09:11>

D, wrote: 7e 07 0a bf 21 89 0b 0a 7e

I, Spa time 14:06, actually 09:11; correcting difference of 295 min

I,   to spa: #<BWA::Messages::SetTime 09:11>

D, wrote: 7e 07 0a bf 21 89 0b 0a 7e

I, Spa time 14:06, actually 09:11; correcting difference of 295 min

I,   to spa: #<BWA::Messages::SetTime 09:11>

D, wrote: 7e 07 0a bf 21 89 0b 0a 7e

I, Spa time 14:06, actually 09:11; correcting difference of 295 min

I,   to spa: #<BWA::Messages::SetTime 09:11>

D, wrote: 7e 07 0a bf 21 89 0b 0a 7e

I, Spa time 14:06, actually 09:11; correcting difference of 295 min

I,   to spa: #<BWA::Messages::SetTime 09:11>

D, wrote: 7e 07 0a bf 21 89 0b 0a 7e

I, Spa time 14:06, actually 09:12; correcting difference of 294 min

I,   to spa: #<BWA::Messages::SetTime 09:12>

D, wrote: 7e 07 0a bf 21 89 0c 1f 7e

I, Spa time 14:06, actually 09:12; correcting difference of 294 min

I,   to spa: #<BWA::Messages::SetTime 09:12>

D, wrote: 7e 07 0a bf 21 89 0c 1f 7e

I, Spa time 14:06, actually 09:12; correcting difference of 294 min

I,   to spa: #<BWA::Messages::SetTime 09:12>

D, wrote: 7e 07 0a bf 21 89 0c 1f 7e

I, Spa time 14:06, actually 09:12; correcting difference of 294 min

I,   to spa: #<BWA::Messages::SetTime 09:12>

D, wrote: 7e 07 0a bf 21 89 0c 1f 7e

I, Spa time 14:06, actually 09:12; correcting difference of 294 min

I,   to spa: #<BWA::Messages::SetTime 09:12>

D, wrote: 7e 07 0a bf 21 89 0c 1f 7e

I,   to spa: #<BWA::Messages::SetTargetTemperature 60°>

D, wrote: 7e 06 0a bf 20 3c a6 7e

I, Spa time 14:06, actually 09:12; correcting difference of 294 min

I,   to spa: #<BWA::Messages::SetTime 09:12>

D, wrote: 7e 07 0a bf 21 89 0c 1f 7e

I, Spa time 14:06, actually 09:12; correcting difference of 294 min

I,   to spa: #<BWA::Messages::SetTime 09:12>

D, wrote: 7e 07 0a bf 21 89 0c 1f 7e

I, Spa time 14:06, actually 09:13; correcting difference of 293 min

I,   to spa: #<BWA::Messages::SetTime 09:13>

D, wrote: 7e 07 0a bf 21 89 0d 18 7e

I,   to spa: #<BWA::Messages::ToggleItem 4>

D, wrote: 7e 07 0a bf 11 04 00 85 7e

I,   to spa: #<BWA::Messages::ToggleItem 5>

I,   to spa: #<BWA::Messages::ToggleItem 5>

D, wrote: 7e 07 0a bf 11 05 00 90 7e

I,   to spa: #<BWA::Messages::ToggleItem 5>

I,   to spa: #<BWA::Messages::ToggleItem 5>

D, wrote: 7e 07 0a bf 11 05 00 90 7e

I,   to spa: #<BWA::Messages::ToggleItem 6>

I,   to spa: #<BWA::Messages::ToggleItem 6>

D, wrote: 7e 07 0a bf 11 05 00 90 7e

D, wrote: 7e 07 0a bf 11 05 00 90 7e

D, wrote: 7e 07 0a bf 11 06 00 af 7e

D, wrote: 7e 07 0a bf 11 06 00 af 7e

I, Spa time 14:06, actually 09:13; correcting difference of 293 min

I,   to spa: #<BWA::Messages::SetTime 09:13>

D, wrote: 7e 07 0a bf 21 89 0d 18 7e

I,   to spa: #<BWA::Messages::ToggleItem 6>

D, wrote: 7e 07 0a bf 11 06 00 af 7e

I,   to spa: #<BWA::Messages::ToggleItem 5>

D, wrote: 7e 07 0a bf 11 05 00 90 7e

I,   to spa: #<BWA::Messages::SetTargetTemperature 60°>

D, wrote: 7e 06 0a bf 20 3c a6 7e

I, Spa time 14:06, actually 09:13; correcting difference of 293 min

I,   to spa: #<BWA::Messages::SetTime 09:13>

D, wrote: 7e 07 0a bf 21 89 0d 18 7e

I, Spa time 14:06, actually 09:13; correcting difference of 293 min

I,   to spa: #<BWA::Messages::SetTime 09:13>

D, wrote: 7e 07 0a bf 21 89 0d 18 7e

I,   to spa: #<BWA::Messages::SetTargetTemperature 80°>

D, wrote: 7e 06 0a bf 20 50 a5 7e

I, Spa time 14:06, actually 09:13; correcting difference of 293 min

I,   to spa: #<BWA::Messages::SetTime 09:13>

D, wrote: 7e 07 0a bf 21 89 0d 18 7e

Search...
Stick to bottom
jamienich commented 2 years ago

Docker environment as follows

TZ Australia/Sydney LOG_LEVEL DEBUG MQTTI_URL mqtt://homeassistant:biglongpassword@192.168.0.194 BRIDGE_IP 192.168.0.101 BRIDGE_PORT 8899 PATH /usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin LANG C.UTF-8 RUBY_MAJOR 2.6 RUBY_VERSION 2.6.9 RUBY_DOWNLOAD_SHA256 6a041d82ae6e0f02ccb1465e620d94a7196489d8a13d6018a160da42ebc1eece GEM_HOME /usr/local/bundle BUNDLE_SILENCE_ROOT_WARNING 1 BUNDLE_APP_CONFIG /usr/local/bundle

jamienich commented 2 years ago

Hi Jim,

We've done some debugging today and encountered the following issues:

  1. Fahrenheit to Celsius conversion formula is incorrect on worldwide balboa app
  2. When setting Celsius as the conversion is wrong it sometimes doesn't apply
  3. Settings are not received from the spa back correctly, too many to list
  4. Timezone, we set the timezone of the elfin and docker container to try and sync the spa
  5. The worldwide balboa app was constantly trying to correct the spa's time, it was looping through the last message and using the last/initial message as the time, so it kept incrementing

We tried restarting several times, setting temps on the bwalink, playing with temps on the spa. Then we decided let's just send hex to the TCP server on the elfin device directly.

And it's working, so we send messages to the elfin using shell command netcat and included the shell commands in the home assistant automation. Now we're going to watch the bwalink app and see what hex it's using for various actions and use netcat to do the same. The spa seems to sometimes accept messages from the bwalink app but it's spotty and I think this could be due to the time being out of sync.

Perhaps at some point I'll edit the worldwide balboa app and let you know how we go. It's really nice how it sets everything up in homeassistant but it just doesn't work for us, perhaps our spa's different or the firmware needs an update.

Overall very happy to have some progress and we're able to automate the spa, so thank you very much kind sir and appreciate all your efforts!

blundell commented 1 year ago

Otherwise lazy people like me will try docker run and set the variables and invariably they'll always fail.

Just been a victim of this. Kept slogging and worked it out! (Official Docs)

docker run -e 'MQTT_URI=mqtt://homeassistantusername:reallylongpassword@172.30.32.x' -e 'BRIDGE_IP=192.168.0.x' --rm ghcr.io/jshank/bwalink:latest

You have to put the env vars first. i.e. -e before --rm

Only a year late :-)