ioBroker.mqtt icon indicating copy to clipboard operation
ioBroker.mqtt copied to clipboard

Type of data point changed without a reason

Open souhl opened this issue 2 years ago • 4 comments

Describe the bug
I am using mqtt to control another software which manages electric car charging and provides values from the installed PV system. To write data to the system it generates an own data point "mqtt.0.evcc.loadpoints.1.mode.set" for the data point "mqtt.0.evcc.loadpoints.1.mode".

"mqtt.0.evcc.loadpoints.1.mode.set" has the value null as it is only for setting values.

iobroker mqtt is changing the data point from string to number when the instance is restarted or somehow periodically.

2022-12-08 10:32:22.724 - info: mqtt.0 (197484) Server: Changed type of "mqtt.0.evcc.loadpoints.1.mode.set" from "string" to "number"
--
2022-12-08 10:32:22.777 - debug: mqtt.0 (197484) stateChange mqtt.0.evcc.loadpoints.1.mode.set: {"val":null,"ack":true,"ts":1670491942775,"q":0,"from":"system.adapter.mqtt.0","user":"system.user.admin","lc":1670491942775}

This is causing problems with my script as I write a string value to the data point.

2022-12-05 05:00:04.815 - warn: javascript.0 (125956) You are assigning a string to the state "mqtt.0.evcc.loadpoints.1.mode.set" which expects a number. Please fix your code to use a number or change the state type to string. This warning might become an error in future versions.
--
2022-12-05 05:00:04.816 - warn: javascript.0 (125956) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1689:20)
2022-12-05 05:00:04.817 - warn: javascript.0 (125956) at Object. (script.js.Tesla:74:17)
2022-12-05 05:00:04.817 - warn: javascript.0 (125956) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1214:38)
2022-12-05 05:00:04.817 - warn: javascript.0 (125956) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:596:29)
2022-12-05 05:00:04.817 - warn: javascript.0 (125956) at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/src/lib/adapter/adapter.js:5909:56)
2022-12-05 05:00:04.817 - warn: javascript.0 (125956) at processImmediate (node:internal/timers:466:21)
2022-12-05 05:00:04.820 - info: javascript.0 (125956) State value to set for "mqtt.0.evcc.loadpoints.1.mode.set" has to be type "number" but received type "string"

Expected behavior
Why the type is changed again and again? I reconfigured it manually, but it is changed back to Number again and again.

Anything I can do in my Script to change it back to String? How this value should be set by MQTT client to be properly recognized as empty string?

Versions:

  • Adapter version: v4.0.7
  • JS-Controller version: 4.0.23
  • Node version: v16.18.1
  • Operating system: ubuntu

souhl avatar Dec 08 '22 09:12 souhl

The adapter is changing the type "once" per runtime if the datatype which comes in via MQTT is a different one as set and the datatype is not "mixed" (A second change of the same state would make it to "mixed" because then the value can not be determined. The issue with MQTT is that the content sent via MQTT can be different for any data which is pushed.

YOur workarounf ´´d would be to set the datatype of the object to "mixed" manually - with this iobroker allows to set differenmt values and it should then stay as mixed

Apollon77 avatar Dec 08 '22 10:12 Apollon77

Anything the client app evcc could do to avoid that?

souhl avatar Dec 08 '22 10:12 souhl

Just "always send the same datatype" ... but honestly ... it is part of MQTT to exactly allow such a behaviour ... so we work around that in iobroker that way. As said: Go to Admin - Objects - find the relevant object - click the pencil icon. change "common.type" balue to "mixed" and save object and restar adapter and it should never happen again

Apollon77 avatar Dec 08 '22 11:12 Apollon77

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

stale[bot] avatar May 09 '23 00:05 stale[bot]