H801 controlling water and air pump automation

I had a sonoff SV connected to a battery which turns a water pump on and off every 30minutes during the day. This pumps water through a hydroponics system in a greenhouse. I want to add an 12volt air pump to the system and have swopped the SV to a H801 with the red channel to the water pump and green to the air pump. at the moment I am turning it on and off via an automation and I have set the color 255,255,0,0 (this sets red and green to full power). I know I could make a double relay using a esp device but I have eight H801 kicking round so thought I would use one of these instead. is it possible to setup an automation in homeassistant that could change the color of the red and green channels. This is my current automation script : -

alias: water pump air pump
description: water pump
trigger:

  • platform: time_pattern
    minutes: /30
    condition:
  • condition: sun
    before: sunset
    after: sunrise
    action:
  • service: homeassistant.turn_on
    data: {}
    target:
    entity_id:
    - light.greenhouse
  • delay:
    hours: 0
    minutes: 1
    seconds: 0
    milliseconds: 0
  • service: homeassistant.turn_off
    data: {}
    target:
    entity_id: light.greenhouse
    mode: single

this works but want to be able to turn the air/water pump independently. This setup all runs off a 40watt solar cell and battery hence the reason why it is not running constantly.

I think you would be able to switch on just the red color channel by setting the color to (255, 0, 0, 0) and the green channel by (0, 255, 0, 0). I am not sure if it will work but please do try it if you haven’t already.

Looks like I didnt understand and setup my mqtt topics the best way.
Everything in my setup worked but could be setup better.
I have now amended the script as follows so the air pump will stay on but water pump is only every 30 mins while the sun is up.

alias: water air pump uses color
description: water air pump
trigger:

  • platform: time_pattern
    minutes: /30
    condition:
  • condition: sun
    before: sunset
    after: sunrise
    action:
  • service: mqtt.publish
    data:
    topic: cmnd/light/greenhouse/color
    payload: ‘255,255,0’
  • delay:
    hours: 0
    minutes: 1
    seconds: 0
    milliseconds: 0
  • service: mqtt.publish
    data:
    topic: cmnd/light/greenhouse/color
    payload: ‘0,255,0’
    mode: single
1 Like

Just out of interest is there a way for me to configure the H801 so it looks like 4 on off switches via homeassistant/mqtt using a template in tasmota or similar. I had thought that the PWM output from the h801 would give me control over how fast the pumps work but they dont seem to like it very much so I only need to turn them on and off the 0 - 255 setting is irrelevant.

You can create mqtt switches for this. Something like this should work.

switch:
  - platform: mqtt
    unique_id: greenhouse_airpump
    name: "Greenhouse Air Pump"
    state_topic: "stat/light/greenhouse"
    command_topic: "cmnd/light/greenhouse/color"
    availability:
      - topic: "lwt/light/greenhouse"
    payload_on: "255,0,0"
    payload_off: "0,0,0"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
  - platform: mqtt
    unique_id: greenhouse_waterpump
    name: "Greenhouse Water Pump"
    state_topic: "stat/light/greenhouse"
    command_topic: "cmnd/light/greenhouse/color"
    availability:
      - topic: "lwt/light/greenhouse"
    payload_on: "0,255,0"
    payload_off: "0,0,0"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false

This should work but there could be one problem, i,e we are sending the color as the on payload, I have a doubt that if this will turn on the device. Please check and do let me know.

If the above mqtt switch is not working, we can create a template switch.

switch:
  - platform: template
    switches:
      air_pump:
        value_template: "{{ is_state('switch.greenhouse', 'on') }}"
        turn_on:
          - service: switch.turn_on
            target:
              entity_id: switch.greenhouse
          - service: mqtt.publish
            data:
              topic: cmnd/light/greenhouse/color
              payload: 255,0,0
        turn_off:
          - service: switch.turn_off
            target:
              entity_id: switch.greenhouse

Please change switch.greenhouse with your H801 entity id. If it is a light then change the services switch.turn_on and switch.turn_off to light.turn_on or light.turn_off respectively.

Hi I have added the script to the configuration.yaml but they switches show as not available

The issue is because of errors in availability topic. please share the logs from the tasmota console.

hopefully these are what you mean

11:50:45 MQT: tele/light/greenhouse/STATE = {“Time”:“2021-04-04T11:50:45”,“Uptime”:“0T02:15:18”,“UptimeSec”:8118,“Heap”:28,“SleepMode”:“Dynamic”,“Sleep”:100,“LoadAvg”:9,“MqttCount”:1,“POWER”:“OFF”,“Dimmer”:100,“Color”:“0,255,0,0,0”,“HSBColor”:“120,100,100”,“Channel”:[0,100,0,0,0],“CT”:153,“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“ON”,“Wifi”:{“AP”:2,“SSId”:“OpenWrt”,“BSSId”:“00:01:36:22:7F:1F”,“Channel”:12,“RSSI”:88,“LinkCount”:1,“Downtime”:“0T00:00:07”}}
11:55:45 MQT: tele/light/greenhouse/STATE = {“Time”:“2021-04-04T11:55:45”,“Uptime”:“0T02:20:18”,“UptimeSec”:8418,“Heap”:28,“SleepMode”:“Dynamic”,“Sleep”:100,“LoadAvg”:9,“MqttCount”:1,“POWER”:“OFF”,“Dimmer”:100,“Color”:“0,255,0,0,0”,“HSBColor”:“120,100,100”,“Channel”:[0,100,0,0,0],“CT”:153,“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“ON”,“Wifi”:{“AP”:2,“SSId”:“OpenWrt”,“BSSId”:“00:01:36:22:7F:1F”,“Channel”:12,“RSSI”:86,“LinkCount”:1,“Downtime”:“0T00:00:07”}}
12:00:00 MQT: stat/light/greenhouse/RESULT = {“POWER”:“ON”,“Dimmer”:100,“Color”:“255,255,0,0,0”,“HSBColor”:“60,100,100”,“Channel”:[100,100,0,0,0],“CT”:153}
12:00:45 MQT: tele/light/greenhouse/STATE = {“Time”:“2021-04-04T12:00:45”,“Uptime”:“0T02:25:18”,“UptimeSec”:8718,“Heap”:28,“SleepMode”:“Dynamic”,“Sleep”:0,“LoadAvg”:14,“MqttCount”:1,“POWER”:“ON”,“Dimmer”:100,“Color”:“255,255,0,0,0”,“HSBColor”:“60,100,100”,“Channel”:[100,100,0,0,0],“CT”:153,“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“ON”,“Wifi”:{“AP”:2,“SSId”:“OpenWrt”,“BSSId”:“00:01:36:22:7F:1F”,“Channel”:12,“RSSI”:86,“LinkCount”:1,“Downtime”:“0T00:00:07”}}
12:00:59 MQT: stat/light/greenhouse/RESULT = {“POWER”:“ON”,“Dimmer”:100,“Color”:“0,255,0,0,0”,“HSBColor”:“120,100,100”,“Channel”:[0,100,0,0,0],“CT”:153}
12:05:45 MQT: tele/light/greenhouse/STATE = {“Time”:“2021-04-04T12:05:45”,“Uptime”:“0T02:30:18”,“UptimeSec”:9018,“Heap”:28,“SleepMode”:“Dynamic”,“Sleep”:0,“LoadAvg”:20,“MqttCount”:1,“POWER”:“ON”,“Dimmer”:100,“Color”:“0,255,0,0,0”,“HSBColor”:“120,100,100”,“Channel”:[0,100,0,0,0],“CT”:153,“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“ON”,“Wifi”:{“AP”:2,“SSId”:“OpenWrt”,“BSSId”:“00:01:36:22:7F:1F”,“Channel”:12,“RSSI”:86,“LinkCount”:1,“Downtime”:“0T00:00:07”}}
12:10:45 MQT: tele/light/greenhouse/STATE = {“Time”:“2021-04-04T12:10:45”,“Uptime”:“0T02:35:18”,“UptimeSec”:9318,“Heap”:28,“SleepMode”:“Dynamic”,“Sleep”:0,“LoadAvg”:21,“MqttCount”:1,“POWER”:“ON”,“Dimmer”:100,“Color”:“0,255,0,0,0”,“HSBColor”:“120,100,100”,“Channel”:[0,100,0,0,0],“CT”:153,“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“ON”,“Wifi”:{“AP”:2,“SSId”:“OpenWrt”,“BSSId”:“00:01:36:22:7F:1F”,“Channel”:12,“RSSI”:88,“LinkCount”:1,“Downtime”:“0T00:00:07”}}
12:15:45 MQT: tele/light/greenhouse/STATE = {“Time”:“2021-04-04T12:15:45”,“Uptime”:“0T02:40:18”,“UptimeSec”:9618,“Heap”:28,“SleepMode”:“Dynamic”,“Sleep”:0,“LoadAvg”:22,“MqttCount”:1,“POWER”:“ON”,“Dimmer”:100,“Color”:“0,255,0,0,0”,“HSBColor”:“120,100,100”,“Channel”:[0,100,0,0,0],“CT”:153,“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“ON”,“Wifi”:{“AP”:2,“SSId”:“OpenWrt”,“BSSId”:“00:01:36:22:7F:1F”,“Channel”:12,“RSSI”:86,“LinkCount”:1,“Downtime”:“0T00:00:07”}}
12:17:45 MQT: stat/light/greenhouse/RESULT = {“POWER”:“ON”}
12:17:45 MQT: stat/light/greenhouse/POWER = ON
12:17:45 MQT: stat/light/greenhouse/RESULT = {“POWER”:“ON”,“Dimmer”:100,“Color”:“255,0,0,0,0”,“HSBColor”:“0,100,100”,“Channel”:[100,0,0,0,0],“CT”:153}
12:17:51 MQT: stat/light/greenhouse/RESULT = {“POWER”:“ON”}
12:17:51 MQT: stat/light/greenhouse/POWER = ON
12:17:51 MQT: stat/light/greenhouse/RESULT = {“POWER”:“ON”,“Dimmer”:100,“Color”:“255,0,0,0,0”,“HSBColor”:“0,100,100”,“Channel”:[100,0,0,0,0],“CT”:153}
12:19:02 CMD: color
12:19:02 MQT: stat/light/greenhouse/RESULT = {“Color”:“255,0,0,0,0”}
12:19:11 MQT: stat/light/greenhouse/RESULT = {“POWER”:“OFF”}
12:19:11 MQT: stat/light/greenhouse/POWER = OFF
12:19:29 CMD: color 0,0,0
12:19:29 MQT: stat/light/greenhouse/RESULT = {“POWER”:“OFF”,“Dimmer”:0,“Color”:“0,0,0,0,0”,“HSBColor”:“0,0,0”,“Channel”:[0,0,0,0,0],“CT”:153}
12:20:45 MQT: tele/light/greenhouse/STATE = {“Time”:“2021-04-04T12:20:45”,“Uptime”:“0T02:45:18”,“UptimeSec”:9918,“Heap”:28,“SleepMode”:“Dynamic”,“Sleep”:100,“LoadAvg”:9,“MqttCount”:1,“POWER”:“OFF”,“Dimmer”:0,“Color”:“0,0,0,0,0”,“HSBColor”:“0,0,0”,“Channel”:[0,0,0,0,0],“CT”:153,“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“ON”,“Wifi”:{“AP”:2,“SSId”:“OpenWrt”,“BSSId”:“00:01:36:22:7F:1F”,“Channel”:12,“RSSI”:96,“LinkCount”:1,“Downtime”:“0T00:00:07”}}
12:25:45 MQT: tele/light/greenhouse/STATE = {“Time”:“2021-04-04T12:25:45”,“Uptime”:“0T02:50:18”,“UptimeSec”:10218,“Heap”:28,“SleepMode”:“Dynamic”,“Sleep”:100,“LoadAvg”:9,“MqttCount”:1,“POWER”:“OFF”,“Dimmer”:0,“Color”:“0,0,0,0,0”,“HSBColor”:“0,0,0”,“Channel”:[0,0,0,0,0],“CT”:153,“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“ON”,“Wifi”:{“AP”:2,“SSId”:“OpenWrt”,“BSSId”:“00:01:36:22:7F:1F”,“Channel”:12,“RSSI”:98,“LinkCount”:1,“Downtime”:“0T00:00:07”}}
12:30:00 MQT: stat/light/greenhouse/RESULT = {“POWER”:“ON”,“Dimmer”:100,“Color”:“255,255,0,0,0”,“HSBColor”:“60,100,100”,“Channel”:[100,100,0,0,0],“CT”:153}
12:30:45 MQT: tele/light/greenhouse/STATE = {“Time”:“2021-04-04T12:30:45”,“Uptime”:“0T02:55:18”,“UptimeSec”:10518,“Heap”:28,“SleepMode”:“Dynamic”,“Sleep”:0,“LoadAvg”:156,“MqttCount”:1,“POWER”:“ON”,“Dimmer”:100,“Color”:“255,255,0,0,0”,“HSBColor”:“60,100,100”,“Channel”:[100,100,0,0,0],“CT”:153,“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“ON”,“Wifi”:{“AP”:2,“SSId”:“OpenWrt”,“BSSId”:“00:01:36:22:7F:1F”,“Channel”:12,“RSSI”:86,“LinkCount”:1,“Downtime”:“0T00:00:07”}}
12:30:59 MQT: stat/light/greenhouse/RESULT = {“POWER”:“ON”,“Dimmer”:100,“Color”:“0,255,0,0,0”,“HSBColor”:“120,100,100”,“Channel”:[0,100,0,0,0],“CT”:153}
12:32:59 MQT: stat/light/greenhouse/RESULT = {“POWER”:“OFF”,“Dimmer”:0,“Color”:“0,0,0,0,0”,“HSBColor”:“0,0,0”,“Channel”:[0,0,0,0,0],“CT”:153}
and from the info page just in case

Please try this.

switch:
  - platform: mqtt
    unique_id: greenhouse_airpump
    name: "Greenhouse Air Pump"
    state_topic: "stat/light/greenhouse"
    command_topic: "cmnd/light/greenhouse/color"
    availability:
      - topic: "tele/light/greenhouse/LWT"
    payload_on: "255,0,0"
    payload_off: "0,0,0"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
  - platform: mqtt
    unique_id: greenhouse_waterpump
    name: "Greenhouse Water Pump"
    state_topic: "stat/light/greenhouse"
    command_topic: "cmnd/light/greenhouse/color"
    availability:
      - topic: "tele/light/greenhouse/LWT"
    payload_on: "0,255,0"
    payload_off: "0,0,0"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false

did try this but still showed as unavailable. The H801 I was using now doesnt work anymore I think the air pump motor causes a short across the green channel. I have swopped it out for another one so will see how long this one lasts. I know someone had used a H801 as a motor controller which is how I got the idea the but the article explaining how this was done has now gone. I assumed that because the mosfets can handle over 4amps each running a 1.5amp water pump and a very small air pump would not cause it any hassles.

In theory what you are trying to do should work. W ejust have to make the code work. Please try this code.

switch:
  - platform: mqtt
    unique_id: greenhouse_airpump
    name: "Greenhouse Air Pump"
    state_topic: "stat/light/greenhouse/POWER"
    command_topic: "cmnd/light/greenhouse/color"
    availability:
      - topic: "tele/light/greenhouse/LWT"
    payload_on: "255,0,0"
    payload_off: "0,0,0"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
  - platform: mqtt
    unique_id: greenhouse_waterpump
    name: "Greenhouse Water Pump"
    state_topic: "stat/light/greenhouse/POWER"
    command_topic: "cmnd/light/greenhouse/color"
    availability:
      - topic: "tele/light/greenhouse/LWT"
    payload_on: "0,255,0"
    payload_off: "0,0,0"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false

They still don’t show up as available.
The automation works fine however using the color change option.
However another H801 became unresponsive over night and for some reason was just pulsing the air pump on and off every few seconds , it was not connected to the wifi the only way to fix it was to reflash it with Tasmota. I have now put a diode and capacitor across the motor terminals to see if this helps with this.

Please try this.

switch:
  - platform: mqtt
    unique_id: greenhouse_airpump
    name: "Greenhouse Air Pump"
    state_topic: "stat/light/greenhouse/POWER"
    command_topic: "cmnd/light/greenhouse/color"
    availability:
      - topic: "tele/light/greenhouse/LWT"
    payload_available: Online
    payload_not_available: Offline
    payload_on: "255,0,0"
    payload_off: "0,0,0"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
  - platform: mqtt
    unique_id: greenhouse_waterpump
    name: "Greenhouse Water Pump"
    state_topic: "stat/light/greenhouse/POWER"
    command_topic: "cmnd/light/greenhouse/color"
    availability:
      - topic: "tele/light/greenhouse/LWT"
    payload_available: Online
    payload_not_available: Offline
    payload_on: "0,255,0"
    payload_off: "0,0,0"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false

Hopefully this should do the trick. But if this doesnot work please the do the following.

switch:
  - platform: template
    switches:
      air_pump:
        value_template: "{{ is_state('switch.greenhouse', 'on') }}"
        turn_on:
          - service: switch.turn_on
            target:
              entity_id: switch.greenhouse
          - service: mqtt.publish
            data:
              topic: cmnd/light/greenhouse/color
              payload: 255,0,0
        turn_off:
          - service: switch.turn_off
            target:
              entity_id: switch.greenhouse

Please change switch.greenhouse with your H801 entity id. If it is a light then change the services switch.turn_on and switch.turn_off to light.turn_on or light.turn_off respectively.

it appears that every time I connect it to the water pump it will work for a few minutes then drops off the network and the only way to recover it is to reflash it. Powering it off /on doesnt cause it to reset or present a AP to connect to. This page refers to a link about using an H801 as a motor controller but the link appears to be dead https://tinkerman.cat/post/closer-look-h801-led-wifi-controller. For now I think I will park this and go down the relay route for switching the pumps on and off. thanks for the suggestions the template did show up as a switch and i could turn it on but couldnt turn it off. Also after a second or 2 the switch on the gui did go back to showing as off although the air pump was still powered.

It seems to be an issue with the tasmota firmware, we can try esphome, the advantage if esphome is that there are more options for automations and all. In theory this setup should work.

I have now used it with ESPHOME with the following yaml file which is the one on the ESPHOME H801 page I just had to add in the MQTT details otherwise ESPHOME was looking at the wrong IP address for the broker and did not show up in the GUI.
Will see how it goes today (fingers crossed )

esphome:
name: h801
platform: ESP8266
board: esp01_1m

wifi:
ssid: “xxxx”
password: “xxxxx”

ap:
ssid: “H801 Fallback Hotspot”
password: “xxxx”
mqtt:
broker: xxx
username: xxx
password: xxx
captive_portal:

logger:

api:

ota:

sensor:

  • platform: wifi_signal
    name: “WiFi Signal h801light”
    update_interval: 60s

output:

  • platform: esp8266_pwm
    pin: 12
    frequency: 1000 Hz
    id: pwm_b
  • platform: esp8266_pwm
    pin: 13
    frequency: 1000 Hz
    id: pwm_g
  • platform: esp8266_pwm
    pin: 15
    frequency: 1000 Hz
    id: pwm_r
  • platform: esp8266_pwm
    pin: 14
    frequency: 1000 Hz
    id: pwm_w

light:

  • platform: rgbw
    name: “H801 Light”
    red: pwm_r
    green: pwm_g
    blue: pwm_b
    white: pwm_w

Actually you don’t need mqtt, you would be able to integrate this with api itself. Just use the esphome integration.

Just removed the MQTT and now the H801 shows as unavailable in the dashboard however the logs from ESPHOME show it connected and sending the wifi signal strength ever minute.

I have other ESPHOME things that work fine (a solar weather station and an ESP32 bluetooth sensor gateway). Can electronics hate a person because these H801s have it in for me.

:grin: Did you add the device to the esphome integration?

no I didn’t , but have now.

image

thankyou

1 Like