Skip to content

Improve support for sp4b class sensors - #495

Merged
felipediel merged 1 commit into
mjg59:masterfrom
felipediel:sp4s
Jan 11, 2021
Merged

Improve support for sp4b class sensors#495
felipediel merged 1 commit into
mjg59:masterfrom
felipediel:sp4s

Conversation

@felipediel

@felipedielfelipediel commented Dec 15, 2020

Copy link
Copy Markdown
Collaborator

Proposed changes

Thanks to @Mister-Slowhand now we know more about the sp4b class. This firmware supports USB and energy monitoring. Not all devices of this class have sensors, but most of them return the keys in response (current, volt, power, totalconsum, overload). Samples:

SCB1E (0x6113)

>>>d.get_state()
{'pwr': 1, 'indicator': 1, 'maxworktime': 0, 'current': 8169, 'volt': 234600, 'power': 1916480, 'totalconsum': 10, 'overload': 0, 'childlock': 0}

SP4 (0x618B)

>>>d.get_state()
{'pwr': 1, 'ntlight': 0, 'indicator': 1, 'usbpwr': 0, 'maxworktime': 0, 'usbmaxworktime': 0, 'ntlbrightness': 100, 'current': -1, 'volt': -1, 'power': -1, 'totalconsum': -1, 'overload': -1, 'childlock': 0}

They return -1 when sensors are not supported, as you can see in the second response. So I am introducing a filter to eliminate these keys.

Before

>>>d.get_state()
{'pwr': 1, 'indicator': 1, 'maxworktime': 0, 'current': -1, 'volt': -1, 'power': -1, 'totalconsum': -1, 'overload': -1, 'childlock': 0}

After

>>>d.get_state()
{'pwr': 1, 'indicator': 1, 'maxworktime': 0, 'childlock': 0}

I am also converting the values to float when sensors are supported.

Before

>>>d.get_state()
{'pwr': 1, 'indicator': 1, 'maxworktime': 0, 'current': 8169, 'volt': 234600, 'power': 1916480, 'totalconsum': 10, 'overload': 0, 'childlock': 0}

After

>>>d.get_state()
{'pwr': 1, 'indicator': 1, 'maxworktime': 0, 'childlock': 0, 'current': 8.169, 'volt': 234.6, 'power': 1916.48, 'totalconsum': 0.01, 'overload': 0.0}

@felipedielfelipediel changed the title Rename SP4B to SP4S and filter unsupported featuresRename SP4B to SP4S and improve get_state()Dec 16, 2020
@felipedielfelipediel changed the title Rename SP4B to SP4S and improve get_state()Improve support for sp4b class sensorsJan 11, 2021
@felipediel
felipediel merged commit ee5a86c into mjg59:masterJan 11, 2021
@felipedielfelipediel mentioned this pull request Jan 20, 2021
Merged
felipediel added a commit to felipediel/python-broadlink that referenced this pull request Jan 29, 2021
felipediel added a commit to felipediel/python-broadlink that referenced this pull request Jan 29, 2021
Sign up for freeto 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.

1 participant

@felipediel