Rinnai Heating/Cooling Wifi Module

Correct - router mode is the one we need. I now realise that the other option means the module is in ap mode, so to use the module you need to connect to the module wifi (which only allows one active connection) so is pretty much pointless.

I put my debugging hat on last night, and after a couple of glasses of wine I came up with a theory to test. I used both scripts this morning and they both worked. I then fired up the app on my mobile and connected to the module. I then tried the scripts, and they timed out. I then waited until the app registered no activity, and lost connection. I then tried the scripts again, and they worked.

What was causing my issue was I had the app open at the same time as running the script, so that was blocking the script from working.

So. It seems that if you connect to the module with the app, that locks the device to that app until you disconnect. It would appear that the module only likes one device to have an active connection at any point in time. In case you were wondering, if you have the app loaded on more than one device, then one will connect via wifi and the rest by the cloud.

The impact this has is that if you have a script that regularly polls the module for the current status, then it will fail whilst you have the mobile app open. It is of course unlikely that you will have the app open and be trying to change the temperature via HA. Frankly, once itā€™s integrated with HA then it is unlikely youā€™ll be wanting or needing to use the mobile app anyway - so itā€™s just something to be aware of, rather than an issue to try to resolve or work around.

2 Likes

Ahh - good find. :wine_glass: typically helps.

That would probably also mean if we have a polling method and separate scripts to send commands, we could face the same issue, so in simplest form will need some sort of locking mechanism.

It is indeed amazing the clarity that you can get from a decent glass of wine, beer, etcā€¦ Itā€™s a programming aid, not a crutch. :slight_smile:

Anyhow, you are right in that it might need some sort of simple lockā€¦ actually maybe simply checking if the port is open before doing anything might be enough to reduce the risk of issuesā€¦

1 Like

Hey guys hows the script been working for you so far?

Iā€™m still only in ā€œplayā€ mode. My plan at the moment is to have the ā€œStatusā€ fetching script to send the status via MQTT. One of the reasons for this is it was then within my capability to write template sensors to extract the various bit of data & then get the lovelace going for it. Iā€™m sure thereā€™s a better way!

e.g

- platform: mqtt
  name: "Brivis MQTT Status"
  state_topic: "homeassistant/brivis/status"
  value_template: "{{ value_json.Status }}"   

- platform: mqtt
  name: "Brivis System"
  state_topic: "homeassistant/brivis/status"
  value_template: "{{ value_json.Status.System.SystemOn }}"
  json_attributes_topic: "homeassistant/brivis/status"
  json_attributes_template: "{{ value_json.Status.System | tojson }}"

- platform: mqtt
  name: "Brivis Evap"
  state_topic: "homeassistant/brivis/status"
  value_template: "{{ value_json.Status.System.EvapMode }}"
  json_attributes_topic: "homeassistant/brivis/status"
  json_attributes_template: "{{ value_json.Status.Evap | tojson }}"

- platform: mqtt
  name: "Brivis Heater"
  state_topic: "homeassistant/brivis/status"
  value_template: "{{ value_json.Status.System.HeaterMode }}"
  json_attributes_topic: "homeassistant/brivis/status"
  json_attributes_template: "{{ value_json.Status.Heater | tojson }}"

- platform: template
  sensors:
    # Overall Brivis
    brivis_mode:
      friendly_name: "Brivis System Mode"
      value_template: >-
          {% if is_state_attr('sensor.brivis_system', 'HeaterMode',True) %}
            Heating
          {% elif is_state_attr('sensor.brivis_system', 'EvapMode',True) %}
            Evap
          {% else %}
            None
          {% endif %}
    brivis_state:
      friendly_name: "Brivis System State"
      value_template: >-
          {% if is_state_attr('sensor.brivis_system', 'SystemOn',True) %}
            On
          {% else %}
            Off
          {% endif %}

    # Brivis Evap
    brivis_evap_state:
      friendly_name: "Brivis Evap State"
      value_template: >-
          {% if is_state_attr('sensor.brivis_evap', 'EvapOn',True) %}
            On
          {% else %}
            Off
          {% endif %}
    brivis_evap_fan:
      friendly_name: "Brivis Evap Fan"
      value_template: >-
          {% if is_state_attr('sensor.brivis_evap', 'FanOn',True) %}
            On
          {% else %}
            Off
          {% endif %}
    brivis_evap_fan_speed:
      friendly_name: "Brivis Evap Fan Speed"
      value_template: >-
          {% if is_state_attr('sensor.brivis_evap', 'FanOn',True) %}
            {{ state_attr('sensor.brivis_evap', 'FanSpeed') }}
          {% else %}
            {{ states('sensor.brivis_evap_fan_speed') }}
          {% endif %}
    brivis_evap_pump:
      friendly_name: "Brivis Evap Pump"
      value_template: >-
          {% if is_state_attr('sensor.brivis_evap', 'WaterPumpOn',True) %}
            On
          {% else %}
            Off
          {% endif %}

itā€™s a fair bit of work!

Iā€™ve been extremely lazy when it comes to this integration. Work has been full on.

Iā€™m still just polling the state through nodered. I must admit itā€™s proving very robust

Howdy. The bridge has been solid, and using the native app and command line scripts are all good. Sadly for me work and family commitments have meant HA has been on the back burner.

Still thinking about how best to do this - I thought that maybe we could use mqtt to collect the status of the system (eg MQTT Sensor - Home Assistant - current fan setting, temperature setting, etc). To send commands to the bridge could just use shell commands (eg Shell Command - Home Assistant)ā€¦ but that seems to be a bit sloppy and it would be nice to use the existing climate integration (eg Climate - Home Assistant)ā€¦ I then start to think that I need to move from raspbian to hass.io and then I spiral into a bad place. :wink:

Basically, no action from me but I promise to try to get a handle on my indecision and look at this next weekend! Maybe I should just do a quick hack for the basics (turn on/off, heat/cool, temperature), and leave the neater integration for laterā€¦

eg: (changing location of script and ip address of your bridge to suit)

shell_command:
  set_brivis_heat_on: 'python /home/homeassistant/.homeassistant/MyTouchClient.py 192.168.0.161 --mode heat --action on'
  set_brivis_off: 'python /home/homeassistant/.homeassistant/MyTouchClient.py 192.168.0.161 --mode heat --action off'

Do you all know of anyone who is attempting to get the Rinnai Control-R module to play with HA? It would basically be like Lyric, in that there would probably be an API like the app uses to get to the Intenet to get the status of my service which would become a custom component.

Iā€™ll sniff my firewall to see if I can see what the appā€™s doing and let you know if I see anything.

Cheers,
Ambi

Wow. I did not know such a thing existed. Now I do, and I have a ā€˜tanklessā€™ water heater that I suspect is compatible, Iā€™m struggling to see how Iā€™d use it. Yes it takes a few seconds for the hot water to start to flow, but itā€™s really not that long compared to when I can be bothered to hit the pre-heat button on one of the wall controllers. Maybe it depends on how much pipe you have between where the heater is and where you are using the water, but ours is a stupid big house and itā€™s not a problemā€¦ having said that, of course I want one nowā€¦ :wink:

Iā€™d see if itā€™s been setup similar to the heater bridge ie find the ip address, and just point a browser to it. If it comes up as a ā€˜mysimplelinkā€™ then thereā€™s a good chance it might be accessible directly in the same wayā€¦

Hi,

Yes, I installed a Rinnai RU-199in. I did all the plumbing and gas and had it looked over by a plumber and inspected by the city.

I like this unit because it has a recirculator that can heat up the water in your lines before you need to use it. It can use existing plumbing and a bypass valve to send hot water via the cold water lines. The Rinnai Control-R module and the app allows you to set a scheduled recirculation or on-demand. They even have a remote button or motion detector to start the recirculation before you need it.

So itā€™s this app Iā€™d like to get some data from. Change the temp of the water, put the heater in ā€œvacation modeā€, change recirc schedule or do an timed recirculation now, etc. The app also reads the heater can gives a bunch of diagnostic data. Oh, and you can do a separate recirculate pump and bypass, but mine is included with the heater.

I had to get another Control-R module. They gave me one for free because the old one would just ā€œforgetā€ my network settings, and Iā€™d have to re-pair it every month or two. Itā€™s been solid since I replaced it.

Iā€™ll check the traffic it uses, and ask the Rinnai customer support folks to see what they can tell me about APIā€™s or third-party development.

Cheers,

Ambi

Well, I managed to convert over to hass.io on the weekend. Wasnā€™t too painful, but I used up all my spare time in cleaning things up. Will have to come back to the Rinnai thing this coming weekend. :slight_smile:

2 Likes

I know this isnā€™t the best work around and wonā€™t work for everyone but smartthings does have this integration working and i still have a hub laying around so i created a virtual switch in smartthings and then used iftt and web hooks in order to call from my node red automations to turn the virtual switch on or off depending on my need, and then use an automation in smart things to control based on the position of the switch. My children will now really hate me as i have a power sensor on the rinnai that turns on an automation when it goes over 10 watts it and starts a 10 min count down. at min 5 lights flash at min 10 lights flash again and water heater turns down the temp to 98 degrees! Now i just need to give the wife an override button in HomeKit or I will be in the dog house for sure.

Hey Chrisā€¦ your scripts work great. I even modified the client script to include support for add-on cooling which seems to work fine. Any more thoughts about how to pubish the results to an MQTT broker?

Cheers,
Dave

Hi David

Good stuff. I havenā€™t had a chance to get back to the scripts for a while so Iā€™ve lost track of where Iā€™m up to I must admit :slight_smile:

Iā€™ve modified the main() function in my current dev ā€œStatusā€ script to this:

def main():
    client = ConnectToTouch(touchIP,touchPort)
    brivisStatus = BrivisStatus()
    HandleStatus(client,brivisStatus)
    statusJsonStr = brivisStatus.Dump()
    if tryMQQT:
        os.system("mosquitto_pub -h 1 <mqttip> -p 1883 -u <mqttuser> -P <mqttpassword> -t homeassistant/brivis/status -m \"{}\"".format(statusJsonStr))
    else:
        print(statusJsonStr)

ā€¦ but I donā€™t think I got it to work.

Thanks, Chris. You set me on the path of getting it to publish to the MQTT broker, but I did it using a bit of different code after installing paho.mqtt.client on hass.io. See below.

I can see the status coming through to the broker. Now I just need to get a custom MQTT component working. Iā€™m getting the error below (just following the simple instructions here https://www.home-assistant.io/cookbook/python_component_mqtt_basic/)

Traceback (most recent call last):
File ā€œ/usr/src/homeassistant/homeassistant/setup.pyā€, line 176, in _async_setup_component
component.setup, hass, processed_config # type: ignore
File ā€œ/usr/local/lib/python3.7/concurrent/futures/thread.pyā€, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File ā€œ/config/custom_components/brivis.pyā€, line 17, in setup
topic = config[DOMAIN].get(CONF_TOPIC, DEFAULT_TOPIC)
AttributeError: ā€˜NodeListClassā€™ object has no attribute ā€˜getā€™

def main():
    client = ConnectToTouch(touchIP,touchPort)
    brivisStatus = BrivisStatus()
    HandleStatus(client,brivisStatus)
    statusJsonStr = brivisStatus.Dump()

    mqtt.Client.connected_flag=False#create flag in class
    broker="<brokerIP>"
    state_topic = 'homeassistant/brivis'
    client = mqtt.Client("python1")             #create new instance 
    client.on_connect=on_connect  #bind call back function
    client.loop_start()
    print("Connecting to broker ",broker)
    client.username_pw_set(username="<mqttbrokerusername>",password="<password>")
    client.connect(broker)      #connect to broker
    while not client.connected_flag: #wait in loop
        print("In wait loop")
        time.sleep(1)
    print("in Main Loop")
    client.publish(state_topic, statusJsonStr)
    client.loop_stop()    #Stop loop 
    client.disconnect() # disconnect

    print(statusJsonStr)     #Comment out if no output is required
1 Like

Hi David

I might look into that MQTT client too. On the HA side, I have done everything as MQTT sensors so far. Pretty laborious but seems to work on the ā€œmonitoringā€ side.
Iā€™ve got some time off over Xmas/NewYear so hope to knock it off then

Cheers,
Chris

Nice work guys, would this MQTT method appear as a climate device in HASS? Like a MQTT Thermostat?

Any updates on this? Anything I can do to help?

I would gladly buy any contributor a coffee for their time on buymeacoffee.com or paypal :slight_smile:

No progress from me :frowning: Partly time/partly I know that this way isnā€™t the best way to do it.

The way I am heading, I donā€™t think it wouldnā€™t appear as a Thermostat. Partly because Iā€™ve got Evap A/C - and it doesnā€™t really make sense for that, and partly because I just donā€™t understand how a thermostat works on the HA side!