Gladys icon indicating copy to clipboard operation
Gladys copied to clipboard

Z2m cover feature

Open atrovato opened this issue 2 years ago • 14 comments

Pull Request check-list

To ensure your Pull Request can be accepted as fast as possible, make sure to review and check all of these items:

  • [x] If your changes affects code, did your write the tests?
  • [x] Are tests passing? (npm test on both front/server)
  • [x] Is the linter passing? (npm run eslint on both front/server)
  • [x] Did you run prettier? (npm run prettier on both front/server)
  • [x] If you are adding a new features/services, did you run integration comparator? (npm run compare-translations on front)
  • [ ] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community for testing before merging.
  • ~~[ ] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)~~
  • ~~[ ] If you are adding a new features/services which needs explanation, did you modify the user documentation? See the GitHub repo and the website.~~
  • ~~[ ] Did you add fake requests data for the demo mode (front/src/config/demo.js) so that the demo website is working without a backend? (if needed) See https://demo.gladysassistant.com.~~

NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.

Description of change

Linked to

  • #1541
  • #1574
  • #1543

Manage cover with z2m.

atrovato avatar Jul 24 '22 15:07 atrovato

Codecov Report

Base: 96.77% // Head: 96.77% // Increases project coverage by +0.00% :tada:

Coverage data is based on head (af30069) compared to base (505df71). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1577   +/-   ##
=======================================
  Coverage   96.77%   96.77%           
=======================================
  Files         654      654           
  Lines        9662     9664    +2     
=======================================
+ Hits         9350     9352    +2     
  Misses        312      312           
Impacted Files Coverage Δ
server/services/zigbee2mqtt/exposes/numericType.js 100.00% <ø> (ø)
server/services/zigbee2mqtt/exposes/enumType.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Jul 24 '22 15:07 codecov[bot]

Patched my production server to test with my device front builded after patch, container restarted

image

discover json

  {
    "name": "Volet chambre Sasha",
    "model": "CCT5015-0001",
    "external_id": "zigbee2mqtt:Volet chambre Sasha",
    "features": [
      {
        "name": "State",
        "min": -1,
        "read_only": false,
        "has_feedback": true,
        "category": "shutter",
        "type": "state",
        "max": 1,
        "unit": null,
        "external_id": "zigbee2mqtt:Volet chambre Sasha:shutter:state:state",
        "selector": "zigbee2mqtt-volet-chambre-sasha-shutter-state-state"
      },
      {
        "name": "Position",
        "min": 0,
        "read_only": false,
        "has_feedback": true,
        "category": "shutter",
        "type": "position",
        "unit": "percent",
        "max": 100,
        "external_id": "zigbee2mqtt:Volet chambre Sasha:shutter:position:position",
        "selector": "zigbee2mqtt-volet-chambre-sasha-shutter-position-position"
      }
    ],
    "should_poll": false,
    "service_id": "0fccf6a6-0377-4678-b244-30d650619a42"
  }

Attempt to save image

Not sure how I can help ( no log in server and no log in front )


I'va added the device manually in db

image

Button not working, level feature does.

VonOx avatar Aug 01 '22 08:08 VonOx

@atrovato If it help

2022-08-03T14:34:20+0200 <error> handleMqttMessage.js:97 () Failed to convert value for device Volet chambre Sasha: Error: Zigbee2mqqt don't handle value "OPEN" for property "state".
    at Zigbee2mqttManager.readValue (/src/server/services/zigbee2mqtt/lib/readValue.js:22:11)
    at /src/server/services/zigbee2mqtt/lib/handleMqttMessage.js:93:31
    at Array.forEach (<anonymous>)
    at Zigbee2mqttManager.handleMqttMessage (/src/server/services/zigbee2mqtt/lib/handleMqttMessage.js:86:41)
    at MqttClient.<anonymous> (/src/server/services/zigbee2mqtt/lib/connect.js:53:12)
    at MqttClient.emit (events.js:400:28)
    at MqttClient._handlePublish (/src/server/services/zigbee2mqtt/node_modules/mqtt/lib/client.js:1277:12)
    at MqttClient._handlePacket (/src/server/services/zigbee2mqtt/node_modules/mqtt/lib/client.js:410:12)
    at work (/src/server/services/zigbee2mqtt/node_modules/mqtt/lib/client.js:321:12)
    at Writable.writable._write (/src/server/services/zigbee2mqtt/node_modules/mqtt/lib/client.js:335:5)
    at doWrite (/src/server/services/zigbee2mqtt/node_modules/readable-stream/lib/_stream_writable.js:409:139)
    at writeOrBuffer (/src/server/services/zigbee2mqtt/node_modules/readable-stream/lib/_stream_writable.js:398:5)
    at Writable.write (/src/server/services/zigbee2mqtt/node_modules/readable-stream/lib/_stream_writable.js:307:11)
    at Socket.ondata (internal/streams/readable.js:731:22)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at Socket.Readable.push (internal/streams/readable.js:206:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

VonOx avatar Aug 03 '22 12:08 VonOx

@VonOx don't you miss a commit? I paste your payload in the demo mode, and I have a better display

image

I think you forgot both 8dc71030d27097cea2d198b99718379378e47af2 and 8f81ccc08a886e771e76e918dbca72644c8a2245 commits (https://github.com/GladysAssistant/Gladys/pull/1576/commits).

atrovato avatar Aug 03 '22 19:08 atrovato

Read again, softly, I agree there is another problem.

atrovato avatar Aug 03 '22 19:08 atrovato

I don't think so, I used a patch file. 🤔

I will manually check every file tomorrow.

VonOx avatar Aug 03 '22 19:08 VonOx

I pushed a new commit on z2m part, for the "readValue" error. Please add 44c105d0ee27e02070a411795fcfd6af3e3f5332 commit too. And keep crossed fingers ;)

atrovato avatar Aug 03 '22 20:08 atrovato

I've applied commit

Not working, and no error in logs for button.

But position throw error. ( the slider is working )

2022-08-04T09:26:07+0200 <error> handleMqttMessage.js:97 () Failed to convert value for device Volet chambre Sasha: Error: Zigbee2mqqt don't handle value "35" for property "position".
    at Zigbee2mqttManager.readValue (/src/server/services/zigbee2mqtt/lib/readValue.js:24:11)
    at /src/server/services/zigbee2mqtt/lib/handleMqttMessage.js:93:31
    at Array.forEach (<anonymous>)
    at Zigbee2mqttManager.handleMqttMessage (/src/server/services/zigbee2mqtt/lib/handleMqttMessage.js:86:41)
    at MqttClient.<anonymous> (/src/server/services/zigbee2mqtt/lib/connect.js:53:12)
    at MqttClient.emit (events.js:400:28)
    at MqttClient._handlePublish (/src/server/services/zigbee2mqtt/node_modules/mqtt/lib/client.js:1277:12)
    at MqttClient._handlePacket (/src/server/services/zigbee2mqtt/node_modules/mqtt/lib/client.js:410:12)
    at work (/src/server/services/zigbee2mqtt/node_modules/mqtt/lib/client.js:321:12)
    at Writable.writable._write (/src/server/services/zigbee2mqtt/node_modules/mqtt/lib/client.js:335:5)
    at doWrite (/src/server/services/zigbee2mqtt/node_modules/readable-stream/lib/_stream_writable.js:409:139)
    at writeOrBuffer (/src/server/services/zigbee2mqtt/node_modules/readable-stream/lib/_stream_writable.js:398:5)
    at Writable.write (/src/server/services/zigbee2mqtt/node_modules/readable-stream/lib/_stream_writable.js:307:11)
    at Socket.ondata (internal/streams/readable.js:731:22)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at Socket.Readable.push (internal/streams/readable.js:206:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

Trying to edit the device ouput this error on front image

VonOx avatar Aug 04 '22 07:08 VonOx

This constant is in a server file server/utils/constants.js. Did you copy it too?

I just rebase from #1576 branch (which was just rebased from latest merged changes on master branch).

atrovato avatar Aug 06 '22 05:08 atrovato

Tests in progress (I hope): https://community.gladysassistant.com/t/gestion-des-volets-roulants/5693/54?u=alextrovato

atrovato avatar Sep 14 '22 19:09 atrovato

It's working now !

Animation

VonOx avatar Sep 15 '22 15:09 VonOx

Nice ! Can I merge ?

Pierre-Gilles avatar Sep 15 '22 15:09 Pierre-Gilles

Yes no error with my device

VonOx avatar Sep 15 '22 15:09 VonOx

I just rebase on master. Thanks @VonOx

atrovato avatar Sep 16 '22 17:09 atrovato

Job #516: Bundle Size — 7.02MB (+0.01%).

ce240d44d95d9ec2086ff1ae4bf4afd000b30fe5 vs a1e079ea339d3a77f3e5a8f2cb6411712e81783b

Changed metrics (2/10)
Metric Current Baseline
Initial JS 2.98MB(+0.02%) 2.98MB
Cache Invalidation 42.34% 66.17%
Changed assets by type (1/7)
            Current     Baseline
JS 4.99MB (+0.01%) 4.99MB

View Job #516 full report

relativeci[bot] avatar Oct 03 '22 03:10 relativeci[bot]