Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 101899

[SOLVED][Modbus switch] Switch not staying on 'on' position ; falling back to 'off' after a couple of seconds

$
0
0

@Tom_11 wrote:

Hi,

I’m new to Home Assistant, but it has already been great playing around with it.

I have a modbus PLC (Wago 750-841) with different in- and outputs that I’m trying to integrate. I have been able to read out which input has been activated in HA, but when I activate an output (coil used for lights) through HA using a switch, after a couple of seconds my switch falls back to the ‘off’ position (but the output actually stays activated in the PLC). I need it to stay on the ‘on’ position until I click on it again manually.
I have tried the following:

  • Defining a modbus switch coil. Problem as described above, I can activate the output, but HA switch falls back to off position.
switch:
  - platform: modbus
    scan_interval: 1
    coils:
    - name: SwitchOut
      slave: 1
      coil: 2
  • Defining a modbus switch register. Setting ‘verify state’ to ‘false’ solves the issue of the switch falling back to the off position, but I need to write the whole register, while I only need to change one coil (or all my other lights will be turned off :slight_smile:) . It does not seems to accept a command value based on a sensor and needs to be a hard coded value?
switch:
  - platform: modbus
    scan_interval: 1
    registers:
    - name: RegisterSwitch1
      slave: 1
      register: 0
      command_on: 1
      command_off: 0
      verify_state: false
  • I tried using a template switch together with a sensor reading my output register to be able to only change the coil I need, while writing the whole register. Unfortunately I seems I cannot set the ‘verify state’ to ‘off’ in the template switch, and my switch falls back to ‘off’ after I have activated it.
switch:
  - platform: template
    switches:
      switchtest:
        value_template: "{{ is_state('sensor.switchtest', 'on') }}"
        turn_on:
          service: modbus.write_register
          data_template:
            unit: 1
            address: 0
            value: "{{ states('sensor.registerout')|int|bitwise_or(1) }}"     
        turn_off:
          service: modbus.write_register
          data_template:
            unit: 1
            address: 0
            value: "{{ states('sensor.registerout')|int|bitwise_and(15-1) }}"      

Any help would be greatly appreciated,

Tom

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 101899

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>