Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with modbus climate for mc6 thermostat #86469

Closed
fapgomes opened this issue Jan 23, 2023 · 12 comments · Fixed by #89695
Closed

Problem with modbus climate for mc6 thermostat #86469

fapgomes opened this issue Jan 23, 2023 · 12 comments · Fixed by #89695

Comments

@fapgomes
Copy link

The problem

The hvac_mode_register and hvac_onoff_register (the write registers), doesn't work, and give the error:

Response(134, 6, IllegalFunction)

when I try to set it.
The read registers works.

Thanks,

What version of Home Assistant Core has the issue?

core-2023.1.7

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

modbus climate

Link to integration documentation on our website

https://www.home-assistant.io/integrations/modbus/

Diagnostics information

No response

Example YAML snippet

# therm 
- name: thermostat_escritorio
type: tcp
host: 192.168.1.95
port: 502
delay: 1
timeout: 10
retries: 5
retry_on_empty: true
message_wait_milliseconds: 200
climates:
- name: "Thermostat_Escritorio"
slave: 5
address: 0
target_temp_register: 64
min_temp: 15
max_temp: 35
scan_interval: 60
temperature_unit: C
data_type: int16
scale: 0.1
offset: 0
precision: 1
hvac_mode_register:
address: 62
values:
state_auto: 4
state_cool: 1
state_heat: 0
state_fan_only: 2
state_dry: 3
hvac_onoff_register: 61

Anything in the logs that might be useful for us?

2023-01-23 16:54:43.775 ERROR (SyncWorker_1) [homeassistant.components.modbus.modbus] Pymodbus: thermostat_escritorio: Exception Response(134, 6, IllegalFunction)

Additional information

No response

@home-assistant
Copy link

Hey there @adamchengtkc, @janiversen, @vzahradnik, mind taking a look at this issue as it has been labeled with an integration (modbus) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of modbus can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign modbus Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


modbus documentation
modbus source
(message by IssueLinks)

@fapgomes
Copy link
Author

@janiversen
Copy link
Member

Response(134, 6, IllegalFunction), comes from the connected device, indicating it does not accept whatever you are doing.

please run debug, as described in the documentation of the modbus integration, without a debug log, I cannot tell you what your device do not like.

@fapgomes
Copy link
Author

In attach:
modbus.txt

As I say on the forum, in openhab with this configuration:

Bridge modbus:tcp:thermostat [ host="192.168.1.95", port=502, id=5, connectTimeoutMillis=15000, connectMaxTries=3 ] {
Bridge poller readonly [ start=0, length=3, refresh=60000, type="holding" ] {
Thing data RoomTemp @ "Piso 1" [ readStart="0", readValueType="int16", readTransform="JS(divide10.js)" ]
Thing data FloorTemp @ "Piso 1" [ readStart="1", readValueType="int16" ]
Thing data Humdity @ "Piso 1" [ readStart="2", readValueType="int16" ]
}
Bridge poller readandwrite [ start=61, length=4, refresh=10000, type="holding" ] {
Thing data Status @ "Piso 1" [ readStart="61", readValueType="int16", writeStart="61", writeValueType="int16", writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil="true"]
Thing data SystemMode @ "Piso 1" [ readStart="62", readValueType="int16", writeStart="62", writeValueType="int16", writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil="true"]
Thing data FanSpeed @ "Piso 1" [ readStart="63", readValueType="int16", writeStart="63", writeValueType="int16", writeType="holding",writeMultipleEvenWithSingleRegisterOrCoil="true"]
Thing data SetTemp @ "Piso 1" [ readStart="64", readValueType="int16", writeStart="64", writeValueType="int16", writeType="holding", writeMultipleEvenWithSingleRegisterOrCoil="true", readTransform="JS(divide10.js)", writeTransform="JS(multiply10.js)" ]
}
}

works.

Thanks

@janiversen
Copy link
Member

And ? There are surely many applications that work, but I am not sure how you see this as helping in identifying your problem.

your device does not like:

Running transaction 25
2023-01-23 19:49:11.305 DEBUG (SyncWorker_0) [pymodbus.transaction] SEND: 0x0 0x19 0x0 0x0 0x0 0x6 0x5 0x6 0x0 0x3d 0x0 0x0
2023-01-23 19:49:11.305 DEBUG (SyncWorker_0) [pymodbus.client.sync] New Transaction state 'SENDING'
2023-01-23 19:49:11.306 DEBUG (SyncWorker_0) [pymodbus.transaction] Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'

See the hex string in the second line. You need to consult the manual of your device to find out why this message is illegal (It is a perfectly legal modbus message).

@fapgomes
Copy link
Author

fapgomes commented Jan 23, 2023

We are not talking about closed source applications...

I write a small python application to make it work:

python teste.py
read bits
---------

read: [0]
write bits
----------

write 1 to 61

read bits
---------

read: [1]

and works...

The device wants a write_multiple_registers:

print('write bits')
print('----------\n')
is_ok = c.write_multiple_registers(61,[1])
if is_ok:
print('write 1 to 61')
else:
print('unable to write 1 to on')
time.sleep(0.5)

If I use write_single_register doesn't work.

Is it possible to do something?

Thanks,

@janiversen
Copy link
Member

I am not sure what you mean by “Not talking about closed source applications”, life would have been so much easier, if you had identified the problem, and opened the issue as “set_hvac_mode does not support write_registers”.

Currently set_hvac_mode does not support write_registers. There is a workaround, make a template climate and call modbus_write instead of set_hvac_mode, remember to call it with an array instead of a integer.

@janiversen
Copy link
Member

Pull requests are welcome, we might look at changing this in a future version (async).

@fapgomes
Copy link
Author

Currently set_hvac_mode does not support write_registers. There is a workaround, make a template climate and call modbus_write instead of set_hvac_mode, remember to call it with an array instead of a integer.

Can you point me the documentation to do that?

@janiversen
Copy link
Member

Search for templates in the home assistant documentation.

@fapgomes
Copy link
Author

Pull requests are welcome, we might look at changing this in a future version (async).

Can I add it as an option? Can you point me the right file to do that?

@janiversen
Copy link
Member

No it should not be an option, but done as we did with modbus_write passing an integer argument calls write_register, passing an integer list calls write_registers.

Just look in the modbus integration.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants