Open supersebbo opened 1 year ago
This is awesome and thanks for providing the feedback! I don't think I ever tried using a non-local serial connection with bwa_mqtt_bridge. I wonder if that's always been the case or there was a code update at some point. I'll look at updating the docker container to "go direct" in the meantime but looking forward to a native ha_addon (that's the dream)! The main reason for the docker container was to avoid having to install Ruby and it's local (and sometimes finicky dependencies). Does the add-on approach work around that?
Great work!
I rebuild my local instance to remove socat and connect directly. So far, so good. I've removed my nightly docker restart script and will let it run for a week. If all goes well, I'll publish a new container next week.
Thanks! Glad to hear it’s working for you.
I have no idea if it was part of the original code or a later update. In the readme it suggests the app needs to know if it’s bridged serial or true Balboa WiFi because they operate differently but so far I’ve not seen evidence of this. There may be hidden issues we’ve yet to encounter but I’m over 24 hours without an issue now.
HomeAssistant add-ons are just docker containers with a bit of supporting meta data and some hooks into HA core. The only thing stopping me from just using your container was that HA provides some useful tools in their base images like bashio which allows you to easily grab environment variables from HA. In the end it was easier to add Ruby and the bridge packages to the HomeAssistant base image rather than try to add the HA tools into yours.
The biggest advantages of running as an HA add on are:
I’ll post the complete add-on code tomorrow, if you want to get prepared then follow the initial steps here https://developers.home-assistant.io/docs/add-ons/tutorial/ to get file system access for local add-on dev (if you haven’t already).
@jshank
Addon test repo here: https://github.com/supersebbo/bwa-mqtt-bridge-addon
I don't want to keep hijacking @ccutrer 's issues tracker to discuss this so lets move the conversation over here: https://github.com/supersebbo/bwa-mqtt-bridge-addon/issues/1
Full installation instructions here https://github.com/supersebbo/bwa-mqtt-bridge-addon/wiki/Installation-&-Run
Just wanted to, firstly, thank @ccutrer again for all his hard work.
Secondly to report that this code seems to work perfectly with non-Balboa RS485-WiFi adaptors, in my case an Elfin-EW11. After spending many hours trying to get @jshank 's bwalink container running reliably (socat was having terrrible problems maintaining the connection), I then tried the telnetd option on the EW11 but this did not seem to be rfc2217 compliant as while I could get raw data out in a telnet session, this gem was unable to communicate with it. So eventually in desperation I flipped the EW11 back to TCP Server mode and just entered the tcp URL into the command line for the gem.
/usr/local/bundle/bin/bwa_mqtt_bridge ${MQTT_URI} tcp://10.10.10.214:9999/
Boom. It just works. So far totally reliable with full reporting and control.
So I then packaged this gem up as a HomeAssistant add-on (which required importing the full contents of the base Ruby Dockerfile as the HA base Dockerfile does not have Ruby support) which then allowed me to use the internal MQTT server of HA - which automagically did the discovery. I'm extermely pleased!
Perhaps something to add to the Wiki?
Elfin Config:
Home Assistant Add-on init script:
#!/usr/bin/with-contenv bashio set -e # Grab the MQTT settings from HAs internal services broker MQTT_HOST=$(bashio::services mqtt "host") MQTT_USER=$(bashio::services mqtt "username") MQTT_PASSWORD=$(bashio::services mqtt "password") # Concat the MQTT URI String MQTT_URI="mqtt://${MQTT_USER}:${MQTT_PASSWORD}@${MQTT_HOST}" # TO DO - pull the TCP URI from the HA Add-On Config UI /usr/local/bundle/bin/bwa_mqtt_bridge ${MQTT_URI} tcp://10.10.10.214:9999/
Home Assistant Add-on Config:
name: "SpaLink" description: "SpaLink Addon Dev" version: "1.0.0" slug: "spalink" init: false startup: application services: - 'mqtt:need' options: bridge_ip: '10.10.10.214' bridge_port: '9999' arch: - aarch64 - amd64 - armhf - armv7 - i386
The Dockerfile is just a merge of the base alpine ruby dockerfile (full copy/paste) with @jshank 's docker config added at the bottom.
End Result:
Over the next few days I'll try to tidy this up into a publishable HA Add-On.
Damn this is clean af. Any way you can share how to setup the view on your samsung tablet ? regards
Damn this is clean af. Any way you can share how to setup the view on your samsung tablet ? regards
Which part specifically? Do you already have Home Assistant server running? If not... you've got a bit of a learning curve coming... https://www.home-assistant.io/getting-started/
The tablet is a Samsung Active tab which are waterproof and can be installed outside, the only issue I have with it is occasionally overheating in direct sunlight. It's running the Home Assistant Android client direct from the Play Store, and connected directly to my HA server.
The code of the dashboard is here, but it's a very simple standard Lovelace view in HA. You'd need to swap out all the sensor/entity names for how you have them configured in your HA setup.
title: Garden
views:
- title: Spa Control
path: spa-control
icon: mdi:hot-tub
type: panel
badges: []
cards:
- type: vertical-stack
cards:
- type: entity
entity: sensor.time
- type: horizontal-stack
cards:
- type: entity
entity: sensor.outside_temperature
- type: entity
entity: sensor.outside_humidity
- type: media-control
entity: media_player.spotify_xxxxxxxxx
- type: horizontal-stack
cards:
- show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: light.decking_lights_light
name: Deck Lights
icon: mdi:lightbulb-spot
- show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: light.garden_light
name: Flood Light
icon: mdi:light-flood-down
- show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: light.garage_lights_light
name: Garage Lights
icon: mdi:garage
- type: horizontal-stack
cards:
- show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: light.gledopto_gl_c_008_light
icon: mdi:hot-tub
name: On/Off
- show_name: true
show_icon: false
type: button
tap_action:
action: call-service
service: light.turn_on
target:
entity_id: light.gledopto_gl_c_008_light
data:
brightness_pct: 100
color_name: blue
entity: light.gledopto_gl_c_008_light
icon: mdi:hot-tub
name: Blue
- show_name: true
show_icon: false
type: button
tap_action:
action: call-service
service: light.turn_on
target:
entity_id: light.gledopto_gl_c_008_light
data:
color_name: green
brightness_pct: 100
entity: light.gledopto_gl_c_008_light
name: Green
icon: mdi:hot-tub
- show_name: true
show_icon: false
type: button
tap_action:
action: call-service
service: light.turn_on
target:
entity_id: light.gledopto_gl_c_008_light
data:
color_name: red
brightness_pct: 100
entity: light.gledopto_gl_c_008_light
name: Red
icon: mdi:hot-tub
- show_name: true
show_icon: false
type: button
tap_action:
action: call-service
service: light.turn_on
target:
entity_id: light.gledopto_gl_c_008_light
data:
color_name: cyan
brightness_pct: 100
entity: light.gledopto_gl_c_008_light
name: Cyan
icon: mdi:hot-tub
show_state: false
- show_name: true
show_icon: false
type: button
tap_action:
action: call-service
service: light.turn_on
target:
entity_id: light.gledopto_gl_c_008_light
data:
color_name: magenta
brightness_pct: 100
entity: light.gledopto_gl_c_008_light
name: Magenta
icon: mdi:hot-tub
- show_name: true
show_icon: false
type: button
tap_action:
action: call-service
service: light.turn_on
target:
entity_id: light.gledopto_gl_c_008_light
data:
color_name: yellow
brightness_pct: 100
entity: light.gledopto_gl_c_008_light
name: Yellow
icon: mdi:hot-tub
- show_name: true
show_icon: false
type: button
tap_action:
action: call-service
service: light.turn_on
target:
entity_id: light.gledopto_gl_c_008_light
data:
brightness_pct: 100
effect: colorloop
entity: light.gledopto_gl_c_008_light
name: Multi
icon: mdi:hot-tub
- type: horizontal-stack
cards:
- type: entity
entity: sensor.bwa_link_hot_tub_current_water_temperature
name: Water Temperature
- type: entity
entity: number.bwa_link_hot_tub_target_water_temperature
name: Water Target Temperature
- type: horizontal-stack
cards:
- show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: switch.bwa_link_hot_tub_pump_1
name: Jet Pump 1
show_state: true
- show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: switch.bwa_link_hot_tub_pump_2
name: Jet Pump 2
show_state: true
- show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: switch.toggle
target:
entity_id: switch.bwa_link_hot_tub_blower
data: {}
entity: binary_sensor.bwa_link_hot_tub_circulation_pump_running
name: Filter Pump
show_state: true
hold_action:
action: more-info
- show_name: true
show_icon: true
type: button
tap_action:
action: none
entity: binary_sensor.bwa_link_hot_tub_heating
name: Heater
show_state: true
Might I suggest putting the Lovelace config and addon setup on a wiki page in this repo? Then send me a PR when it's ready to link to it from the readme.
Just wanted to, firstly, thank @ccutrer again for all his hard work.
Secondly to report that this code seems to work perfectly with non-Balboa RS485-WiFi adaptors, in my case an Elfin-EW11. After spending many hours trying to get @jshank 's bwalink container running reliably (socat was having terrrible problems maintaining the connection), I then tried the telnetd option on the EW11 but this did not seem to be rfc2217 compliant as while I could get raw data out in a telnet session, this gem was unable to communicate with it. So eventually in desperation I flipped the EW11 back to TCP Server mode and just entered the tcp URL into the command line for the gem.
/usr/local/bundle/bin/bwa_mqtt_bridge ${MQTT_URI} tcp://10.10.10.214:9999/
Boom. It just works. So far totally reliable with full reporting and control.
So I then packaged this gem up as a HomeAssistant add-on (which required importing the full contents of the base Ruby Dockerfile as the HA base Dockerfile does not have Ruby support) which then allowed me to use the internal MQTT server of HA - which automagically did the discovery. I'm extermely pleased!
Perhaps something to add to the Wiki?
Elfin Config:
Home Assistant Add-on init script:
Home Assistant Add-on Config:
The Dockerfile is just a merge of the base alpine ruby dockerfile (full copy/paste) with @jshank 's docker config added at the bottom.
End Result:
Over the next few days I'll try to tidy this up into a publishable HA Add-On.