iobroker-community-adapters / ioBroker.shelly

Integrate your Shelly devices into ioBroker via MQTT or CoIoT
Other
162 stars 65 forks source link

[Bug]: ShellyPlus2PM CoverMode SetPosition leads to UpDownLoop #885

Open vavuum opened 11 months ago

vavuum commented 11 months ago

I'm sure that

Shelly device

ShellyPlus2PM firmware 1.03

Protocol

MQTT

The problem

Wenn ich den Wert von Cover0.Position (unbestätigt) ändere, beginnt der Rollladen abwechselnd hoch und runter zu fahren. Vermutlich wir der vom Shelly während der Fahrt kontinuierlich aktualierte Wert als neue Eingabe gewertet.

iobroker.current.log (in debug mode!)

No response

Version of nodejs

v18.17.1

Version of ioBroker js-controller

7.1.4

Version of adapter

latest

github-actions[bot] commented 11 months ago

Thanks for reporting a new issue @vavuum!

  1. Please make sure your topic is not covered in the documentation
  2. Ensure that you use the latest beta version (not the current stable version): 6.6.1
  3. Please attach all necessary log files (in debug mode!), screenshots and other information to reproduce this issue
  4. Search for the issue topic in other/closed issues to avoid duplicates!

    Otherwise this issue will be closed.

klein0r commented 6 months ago

Vermutlich wir der vom Shelly während der Fahrt kontinuierlich aktualierte Wert als neue Eingabe gewertet.

Das ist technisch nicht möglich. Aber ohne Debug-Log werden wir das wohl nie erfahren.

lombardi-zz commented 6 months ago

Dasselbe Problem hier. Auch bei Lichtschaltern als Taster konfiguriert tritt das auf. Wenn ich „ Enable RPC over MQTT“ deaktiviere und die Befehle per HTTP sende, funktioniert es, da ich den Datenpunkt nicht mehr nutze bzw. Nur noch auslese. Bin derselben Meinung, dass ein Update des Datenpunktes ein neues Update triggert.

klein0r commented 6 months ago

Still no debug log

lombardi-zz commented 6 months ago

Give me some days. I will attach a log then. But in my opinion it‘s easy to reproduce the issue.

klein0r commented 6 months ago

The problem is: time. I'm not using any Shelly in my installation. I just have a bunch of test devices which are not connected to anything. To prepare such a setup takes a lot of time.

lombardi-zz commented 6 months ago

Perhaps change cover Position Topic in gen2-helper.js to: This would also solve the issue by using YAHKA to get the proper Status by using current and target position.

   deviceObj[`Cover${coverId}.TargetPosition`] = {
        device_mode: 'cover',
        mqtt: {
            mqtt_publish: `<mqttprefix>/status/cover:${coverId}`,
            mqtt_cmd: '<mqttprefix>/rpc',
            mqtt_cmd_funct: (value, self) => {
                return JSON.stringify({
                    id: self.getNextMsgId(),
                    src: 'iobroker',
                    method: 'Cover.GoToPosition',
                    params: { id: coverId, pos: value },
                });
            },
        common: {
            name: 'Position',
            type: 'number',
            role: 'level.blind',
            read: true,
            write: true,
            def: 0,
            unit: '%',
            min: 0,
            max: 100,
        },
    };

    deviceObj[`Cover${coverId}.CurrentPosition`] = {
    device_mode: 'cover',
    mqtt: {
        mqtt_publish: `<mqttprefix>/status/cover:${coverId}`,
        mqtt_publish_funct: value => JSON.parse(value).current_pos
        },
        common: {
            name: 'Position',
            type: 'number',
            role: 'level.blind',
            read: true,
            write: true,
            def: 0,
            unit: '%',
            min: 0,
            max: 100,
        },
    };
lombardi-zz commented 6 months ago

It seems that an update of current_pos is triggering a new Cover.GoToPosition:

    deviceObj[`Cover${coverId}.Position`] = {
        device_mode: 'cover',
        mqtt: {
            mqtt_publish: `<mqttprefix>/status/cover:${coverId}`,
            mqtt_publish_funct: value => JSON.parse(value).current_pos,  <-- HERE
            mqtt_cmd: '<mqttprefix>/rpc',
            mqtt_cmd_funct: (value, self) => {
                return JSON.stringify({
                    id: self.getNextMsgId(),
                    src: 'iobroker',
                    method: 'Cover.GoToPosition',                 <-- HERE
                    params: { id: coverId, pos: value },
                });
            },
        },
        common: {
            name: 'Position',
            type: 'number',
            role: 'level.blind',
            read: true,
            write: true,
            def: 0,
            unit: '%',
            min: 0,
            max: 100,
        },
    };

`
mroesel commented 1 month ago

Hatte das gleiche Problem. Hab QoS auf 0 gesetzt. danach war Ruhe