Has anyone used Dingtian 8ch Ethernet Relay?

Hi i have found the solution to my error above. It is because the user manual has the old way of doing the code. Here is a fantastic video of how to do it as expected now Your MQTT Sensors need your attention

Thanks for the answer.

Any idea if the firmware could be modified to allow esphome?

Hello Stef,

It looks like that it would be possible! There is a pin layout of the print with also the GPIO pins.
So flashing ESPHOME and make some switches and inputs sounds possible.

Thetmar

Hey Thetmar,

I looked in to this and it’s not possible because the bootloader is locked.

So if I get it right

1 Like

Actually, I got the LWT function functioning perfectly fine on my relay:

mqtt:
  button:
    - unique_id: button-gate-open
      name: "Open Gate"
      command_topic: "/dingtian/relay1234/in/control"
      availability:
        - topic: "/dingtian/relay1234/out/lwt_availability"
          payload_available: "online"
          payload_not_available: "offline"
      payload_press: '{\"type\":\"JOGGING\",\"idx\": \"1\",\"status\":\"ON\",\"time\":\"5\",\"pass\":\"0\"}'
      qos: 0
      retain: false
      device:
        name: "Dingtian 8 port Relay 1234"
        connections:
          - ["mac", "12:34:56:78:90:AB"]
        configuration_url: "http://192.168.1.12"
        hw_version: "V3.6J"
        sw_version: "V3.1.1759A"
        manufacturer: "Dingtian"
        model: "DT R008"
        suggested_area: "Outside"

The gate control only needs a momentary input, so I thought it would be better to add it as a button…
I have no idea why I have to escape all the quotation marks in the payload but the configuration check complains if I don’t do so…
Nice addition is the device info, like this it gathers all relevant info for the button and groups all buttons and binary_sensors from this device. I quite like it!

Just curious if anyone has a comment on the reliability of these Dingtian relay boards? Also, is there a delay with their input sensors, or is HA notified immediately? Thanks!

I have mine for over a year and they are working really well.
I use MQTT with HA and the response is instant. (less than a second)

I’m on firmware V3.1.1384 because in the newer firmware there is an issue with MQTT. They are still looking for a fix (I mailed them 3 weeks ago regarding the issue)

They use their own firmware on the ESP32 boards so you can’t flash other firmware on it (no ESPhome by example)

1 Like

Try this one GitHub - kecajtop/dtr0xx_io

anymore information? Does this flash the current software on them? how do I install this?

Thanks in advance

I have 4 Dingtian relays (8 and 4 channels) working with Home Assistant with MQTT. Everything works fine, but I have a minor issue with the digital inputs:

When a relay loses network connection it triggers an OFF command on reconnection. I use the digital inputs to trigger automations (i.e. I don’t use the relay’s direct trigger of the relay) so on reconnection the automation is triggered. (Not sure if the relay considers network connection loss as a restart. My relay has the power failure recovery activated and defaulting to OFF)

Does anyone know how to avoid this? I am guessing the “IP WatchDog” in the relay UI could address it, but I don’t really understand the settings. Has anybody experimented with these settings? (BTW, I have NOT enabled the “IP WatchDog” on my relays)

have you tried to contact Stephen from Dingtian about this issue?

Will try. Thank you

I have one of the dingtian relay boards, and I asked them to ship it with dev firmware. Then, I was able to flash esphome, which I use to control it instead of mqtt.

Yeah, I you have the dev firmware you can flash esphome over it.

can you share it? or isn’t that possible?

Due to the way the IO expanders are wired & esphome’s implementation, you can only set up input OR output :confused:

substitutions:
  device_name: radiant_controller

esphome:
  name: radiant_controller
  friendly_name: Radiant Controller
  on_boot:
    then:
      pcf85063.read_time: # read RTC time once the system boots

esp32:
  board: esp32dev

api:

ota:

# see https://github.com/dtlzp/relay_dev_demo

# Enable logging
logger:
  level: DEBUG
  baud_rate: 0

ethernet:
  type: JL1101
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  power_pin: GPIO12
  clk_mode: GPIO17_OUT
  phy_addr: 0

uart:
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 9600
  stop_bits: 1

modbus:
  flow_control_pin: GPIO33
  id: modbus1

modbus_controller:
  id: modbus_ctl
  address: 0x1
  modbus_id: modbus1
  setup_priority: -10

i2c:
  scl: GPIO32
  sda: GPIO16
  scan: true
  id: i2c_bus

sn74hc595:
  - id: sn74hc595_hub
    data_pin: GPIO13 #SER
    clock_pin: GPIO14 #SRCLK
    latch_pin: GPIO15 #RCLK
    oe_pin: GPIO0
    sr_count: 2

#sn74hc165:
#  - id: sn74hc165_hub
#    clock_pin: GPIO14
#    data_pin: GPIO35
#    load_pin: GPIO0
#    clock_inhibit_pin: GPIO15
#    sr_count: 2

time:
  - platform: pcf85063
    update_interval: never # internal clock is fine for general use
  - platform: homeassistant
    on_time_sync:
      then:
        pcf85063.write_time: # sync RTC to HA when available


switch:
  - platform: gpio
    name: Factory LED
    pin:
      number: GPIO2
  - platform: gpio
    name: Relay 16 control
    id: relay16ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 0
      inverted: false
  - platform: gpio
    name: Relay 15 control
    id: relay15ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 1
      inverted: false
  - platform: gpio
    name: Relay 14 control
    id: relay14ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 2
      inverted: false
  - platform: gpio
    name: Relay 13 control
    id: relay13ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 3
      inverted: false
  - platform: gpio
    name: Relay 12 control
    id: relay12ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 4
      inverted: false
  - platform: gpio
    name: Relay 11 control
    id: relay11ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 5
      inverted: false
  - platform: gpio
    name: Relay 10 control
    id: relay10ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 6
      inverted: false
  - platform: gpio
    name: Relay 9 control
    id: relay9ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 7
      inverted: false
  - platform: gpio
    name: Relay 8 control
    id: relay8ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 8
      inverted: false
  - platform: gpio
    name: Relay 7 control
    id: relay7ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 9
      inverted: false
  - platform: gpio
    name: Relay 6 control
    id: relay6ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 10
      inverted: false
  - platform: gpio
    name: Relay 5 control
    id: relay5ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 11
      inverted: false
  - platform: gpio
    name: Relay 4 control
    id: relay4ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 12
      inverted: false
  - platform: gpio
    name: Relay 3 control
    id: relay3ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 13
      inverted: false
  - platform: gpio
    name: Relay 2 control
    id: relay2ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 14
      inverted: false
  - platform: gpio
    name: Relay 1 control
    id: relay1ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 15
      inverted: false

output:
  - platform: sigma_delta_output
    update_interval: 30s
    id: heater_room1
    turn_on_action:
      # TODO here we need to check that the floor isn't overheating
      # really should register intention in a template
      - switch.turn_on: relay1ctl
    turn_off_action:
      - switch.turn_off: relay1ctl

climate:
  platform: pid
  name: PID Climate Controller
  sensor: temp_room1
  default_target_temperature: 21
  heat_output: heater_room1
  control_parameters:
    kp: 0
    ki: 0
    kd: 0
    output_averaging_samples: 5
    derivative_averaging_samples: 5
  deadband_parameters:
    threshold_high: 0.5
    threshold_low: -0.5

binary_sensor:
  - platform: gpio
    name: Factory Button
    pin:
      number: GPIO34
      inverted: true
# - platform: gpio
#   name: input8
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 0
#     inverted: true
# - platform: gpio
#   name: input7
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 1
#     inverted: true
# - platform: gpio
#   name: input6
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 2
#     inverted: true
# - platform: gpio
#   name: input5
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 3
#     inverted: true
# - platform: gpio
#   name: input4
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 4
#     inverted: true
# - platform: gpio
#   name: input3
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 5
#     inverted: true
# - platform: gpio
#   name: input2
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 6
#     inverted: true
# - platform: gpio
#   name: input1
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 7
#     inverted: true
# - platform: gpio
#   name: input16
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 8
#     inverted: true
# - platform: gpio
#   name: input15
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 9
#     inverted: true
# - platform: gpio
#   name: input14
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 10
#     inverted: true
# - platform: gpio
#   name: input13
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 11
#     inverted: true
# - platform: gpio
#   name: input12
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 12
#     inverted: true
# - platform: gpio
#   name: input11
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 13
#     inverted: true
# - platform: gpio
#   name: input10
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 14
#     inverted: true
# - platform: gpio
#   name: input9
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 15
#     inverted: true

Hi,
Does anyone have the 4CH esphome config file? It doesn’t have any SN74HC ships.
I’ve used this with MQTT and Home Assistant but relay reset on connection reset and some other things make it unreliable, I did even have a problem where MQTT show relay is ON but it’s actually OFF!

Can you advise how you flashed it?
Via gui or do we need something else?
Thank you

I connected an esp programmer to the header on the board. They’re GitHub repo documents which pins are which on the header.

You can not flash it unless you have the dev version, the normal version have some sort of bootloader lock and even if you flash it, it won’t boot.
I’m trying to disolder the ESP32 chip and solder an other one!

You can find indpeth discussion here: Dingtian IOT Relay - Let's Control It