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

Allow configuring transmit power on TI Z-Stack routers #1886

Merged
merged 2 commits into from
Nov 4, 2022

Conversation

TheJulianJES
Copy link
Collaborator

@TheJulianJES TheJulianJES commented Nov 3, 2022

Changes

Z-Stack router firmware 20221102 and above adds a transmit_power attribute on the Basic cluster.
This quirk makes that attribute accessible through ZHA.

I also added TubesZB/tubeszb.router to the signature, even though it doesn't support the configurable attribute yet, but I'm sure he'll add it in the future. cc @tube0013 (still on the Z-Stack dev branch as of right now though)
Edit: It's possible that no new updates will be made for "TubesZB" custom router firmware and as current versions don't support the configurable attribute, I removed it from the signature entirely.

(A config entity in ZHA could also be added. For older versions, a warning debug message will be printed on startup saying that the attribute isn't supported for routers running older firmware.)
(PR for ZHA config entity: home-assistant/core#81520)

Closes #1884
Z2M converter commit: Koenkk/zigbee-herdsman-converters@8fb1ba4
Z-Stack firmware.patch commit: Koenkk/Z-Stack-firmware@3d43a50
Z-Stack issue: Koenkk/Z-Stack-firmware#341

The quirk is tested and works.

Testing

This quirk will likely be available in Home Assistant 2022.12.0 or later.
If you want to test it now, download the router.py file and put it in your configured custom_zha_quirks directory. Then, restart Home Assistant.
For now, you can change the transmit power using the "Manage Zigbee Device" UI -> "Clusters".
Select BasicCluster and transmit_power. Then, you can read the attribute. If your firmware supports it, it'll return a number (like 5 or 9). If your firmware is still unsupported, it'll return None and you'll need to update your router firmware.
To change the transmit power, simply replace the number in the upper text field (leave the lower text field empty) and then click "Set Zigbee attribute". You can re-read the attribute to verify that the change worked.

Also, make sure to remove the custom quirk as soon as it's merged into Home Assistant.

@coveralls
Copy link

coveralls commented Nov 3, 2022

Pull Request Test Coverage Report for Build 3390045545

  • 11 of 11 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 82.806%

Totals Coverage Status
Change from base Build 3377165510: 0.03%
Covered Lines: 6256
Relevant Lines: 7555

💛 - Coveralls

@codecov-commenter
Copy link

Codecov Report

Base: 82.78% // Head: 82.80% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (993121c) compared to base (79db3a2).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1886      +/-   ##
==========================================
+ Coverage   82.78%   82.80%   +0.02%     
==========================================
  Files         243      244       +1     
  Lines        7544     7555      +11     
==========================================
+ Hits         6245     6256      +11     
  Misses       1299     1299              
Impacted Files Coverage Δ
zhaquirks/texasinstruments/router.py 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.

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

@tube0013
Copy link
Contributor

tube0013 commented Nov 3, 2022

NIce, I actually just flashed a router a few minutes ago to look at this. Honestly not sure I will be continuing to compile my own fw.

@TheJulianJES
Copy link
Collaborator Author

Should I remove your model ID from the signature for now? (can also be added back later of course)

@tube0013
Copy link
Contributor

tube0013 commented Nov 3, 2022

Yeah, remove it for now. thanks!

@tube0013
Copy link
Contributor

tube0013 commented Nov 3, 2022

Quirk works for me🎉

@Hedda
Copy link
Contributor

Hedda commented Nov 4, 2022

FYI, the premium version of PTVO Zigbee Configurable Firmware has the same function when built Zigbee Router firmware for CC2652P and CC1352P with it and enable its ”RF signal level” sensor -> https://ptvo.info/zigbee-configurable-firmware-features/rf-signal-level-control/

RF signal level control

The firmware can control RF signal strength for all chips with a power amplifier. This feature allows you to find tune your mesh network and exclude situations when a device constantly jumps from one router to another because a signal level from both router is almost identical.

The firmware also allows you to control signal level remotely in run-time.

⚠️ THIS FEATURE IS AVAILABLE IN THE PREMIUM VERSION

To control signal level, you should add the “RF signal level” sensor on any output, using any virtual pin. The “Signal strength level” parameter defines an initial value after flashing or resetting, where 0 is the lowest signal level and 20 is the highest signal level. Please note, this number is not a precise number of signal power in dBm.

RF signal level configuration
To control signal strength remotely, you should write the corresponding level value to the configured endpoint (e.g., output 5 will work on endpoint 5).

⚠️ Please be careful because this action has an immediate effect, and your device may become unresponsive if a signal strength is too small.

You can also create a custom converter for Z2M on the “Expert” tab that adds the corresponding option field to exposes.

The firmware does not send the configured signal strength value with periodic reports because this value is constant. If you need to get this value, you may use the “Refresh” button in exposes or the “get” via MQTT.

Zigbee2MQTT commands

read – immediately reads the signal strength value

Topic: zigbee2mqtt/[friedly_name]/get/[channel]
Channel: l1, l2, l3 … l16
Payload: 1
Returns the channel state: {"[channel]": value}
write – writes the signal strength value

Topic: zigbee2mqtt/[friedly_name]/set
Payload: {"[channel]": value}
Channel: l1, l2, l3 … l16

@ErikApption
Copy link

I have HA 2023.4.4 but I don't see transmit_power for my Sonoff CC2652P - is this expected?

@TheJulianJES
Copy link
Collaborator Author

@ErikApption Make sure you're running a somewhat recent Z-Stack router release on that stick.
You might need to re-pair it after updating.

@ErikApption
Copy link

@ErikApption Make sure you're running a somewhat recent Z-Stack router release on that stick. You might need to re-pair it after updating.

I do have last week's firmware installed but I did install the firmware after configuring the radio. How would I re-pair? Would this be a migrate radio thing?

@TheJulianJES
Copy link
Collaborator Author

TheJulianJES commented Apr 17, 2023

This PR is for configuring transmit power on Z-Stack routers, not coordinators.

If you want to change transmit power for your coordinator, then have a look at the zigpy repo.
It can be done via YAML.

@ErikApption
Copy link

This PR is for configuring transmit power on Z-Stack routers, not coordinators.

If you want to change transmit power for your coordinator, then have a look at the zigpy repo. It can be done via YAML.

Ohhhhh thanks for the clarification!!! I missed that detail. I did see yaml for changing transmit power on coordinator for zigbee2mqtt but haven't been able to trace the details for HA

@TheJulianJES
Copy link
Collaborator Author

Check this: https://github.com/zigpy/zigpy-znp#configuration

Only paste in the first couple of rows that you actually need.

Most of the times, you shouldn't really increase transmit power though, as it'll only "shout louder", but won't hear other devices better.

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

Successfully merging this pull request may close these issues.

[Device Support Request] Configurable Z-Stack Router firmware radio transmit_power
7 participants