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

[Bug]: Values missing from BLU Button 1 #914

Closed
3 tasks done
drb-germany opened this issue Dec 17, 2023 · 10 comments
Closed
3 tasks done

[Bug]: Values missing from BLU Button 1 #914

drb-germany opened this issue Dec 17, 2023 · 10 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@drb-germany
Copy link

I'm sure that

  • This issue is still present in the current beta version of this adapter
  • There is no other (open) issue with the same topic (used the search)
  • This issue is not described in the adapter documentation / FAQ

Shelly device

BLU Button 1

Protocol

MQTT

The problem

Script installed on Shelly PlusPlugS. Events of BLU Button 1 are reported to iobroker, but part of the payload (e.g. the pid) is missing in iobroker, but present in the script.

image
image

iobroker.current.log (in debug mode!)

No response

Version of nodejs

v16.20.2

Version of ioBroker js-controller

7.1.6

Version of adapter

v6.6.1

Copy link

Thanks for reporting a new issue @drb-germany!

  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
Copy link
Contributor

klein0r commented Dec 18, 2023

Script installed on Shelly PlusPlugS. Events of BLU Button 1 are reported to iobroker, but part of the payload (e.g. the pid) is missing in iobroker, but present in the script.

As you see, unpackedData is logged, but message is build separately. Why do you need those information? Why is the pid useful?

@drb-germany
Copy link
Author

unpackedData is contained in the message, so it reaches iobroker, but is not inserted as an object? I want to monitor the pid in order to react on a pressed button. The button value only changes if the number-of-repeats is changing.

@klein0r
Copy link
Contributor

klein0r commented Dec 18, 2023

Sorry, misunderstood the issue. Yes, I've implemented a filter to avoid useless information in the states:

ioBroker.shelly/main.js

Lines 301 to 339 in 4163057

const typesList = {
rssi: { type: 'number', unit: 'dBm' },
battery: { type: 'number', unit: '%' },
temperature: { type: 'number', unit: '°C' },
humidity: { type: 'number', unit: '%' },
illuminance: { type: 'number' },
motion: { type: 'number' },
window: { type: 'number' },
button: { type: 'number' },
rotation: { type: 'number' },
};
await this.extendObjectAsync(`ble.${val.srcBle.mac}`, {
type: 'device',
common: {
name: val.srcBle.mac,
icon: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMjAgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuNC4yIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIzIEZvbnRpY29ucywgSW5jLiAtLT48cGF0aCBkPSJNMTk2LjQ4IDI2MC4wMjNsOTIuNjI2LTEwMy4zMzNMMTQzLjEyNSAwdjIwNi4zM2wtODYuMTExLTg2LjExMS0zMS40MDYgMzEuNDA1IDEwOC4wNjEgMTA4LjM5OUwyNS42MDggMzY4LjQyMmwzMS40MDYgMzEuNDA1IDg2LjExMS04Ni4xMTFMMTQ1Ljg0IDUxMmwxNDguNTUyLTE0OC42NDQtOTcuOTEyLTEwMy4zMzN6bTQwLjg2LTEwMi45OTZsLTQ5Ljk3NyA0OS45NzgtLjMzOC0xMDAuMjk1IDUwLjMxNSA1MC4zMTd6TTE4Ny4zNjMgMzEzLjA0bDQ5Ljk3NyA0OS45NzgtNTAuMzE1IDUwLjMxNi4zMzgtMTAwLjI5NHoiLz48L3N2Zz4=',
},
native: {},
}, { preserve: { common: ['name'] } });
for (const [key, value] of Object.entries(val.payload)) {
if (Object.keys(typesList).includes(key)) {
await this.extendObjectAsync(`ble.${val.srcBle.mac}.${key}`, {
type: 'state',
common: {
name: key,
type: typesList[key].type,
role: 'value',
read: true,
write: false,
unit: typesList[key]?.unit,
},
native: {},
});
await this.setStateAsync(`ble.${val.srcBle.mac}.${key}`, { val: value, ack: true, c: val.src });
}
}

@drb-germany
Copy link
Author

OK. I think the pid is really necessary, so that you can safely react on a pressed button:

on('shelly.0.ble.b4:XX:YY:ZZ:76:94.pid', function (obj) {
    // react on change
});

@klein0r
Copy link
Contributor

klein0r commented Jan 15, 2024

so that you can safely react on a pressed button:

And why it's not safe to react on the button state?

on({ id: 'shelly.0.ble.b4:XX:YY:ZZ:76:94.button', change: 'any' }, (obj) => {
    // react on update
});

@klein0r klein0r added enhancement New feature or request question Further information is requested labels Jan 15, 2024
@drb-germany
Copy link
Author

The variable button contains the number of times the button was pressed, e.g. 1, 2 or 3. If I press the button once I do not trigger a change event unless I have pressed it twice or three times before, because the variable does not change. Only the pid safely changes every time an event is received.

@klein0r
Copy link
Contributor

klein0r commented Jan 15, 2024

Of course, but an update event will be triggered. (change: 'any' is the default, no state change is required).

This is the same behaviour like in many other adapters too (like zigbee).

@drb-germany
Copy link
Author

Sorry @klein0r, I thought I tested this and did not get a change event, but I might have made a mistake there. In this case, of course, this would be obsolete for the change event. Still, the pid might be useful, for example, to check if a button press has been missed, so I so do not see a downside in including it.

@drb-germany
Copy link
Author

Forgot to add the change: 'any' code, adding this will always trigger the function, as you have written. I will close this issue accordingly. Thank you for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants