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

emeter output is not usable #10

Closed
gck303 opened this issue Oct 20, 2023 · 1 comment · Fixed by #12
Closed

emeter output is not usable #10

gck303 opened this issue Oct 20, 2023 · 1 comment · Fixed by #12
Assignees

Comments

@gck303
Copy link

gck303 commented Oct 20, 2023

I have tried to use the emeter output, but it has a couple of issues:

  • it is surrounded by <>
  • all the different parameters are within a single payload

I have edited the code to remove the <> send multiple messages. Can this be incorporated in the standard code?

`async def handle_emeter_event_kasa(
kasa_emeter: KasaEmeterEvent, run_state: RunState, mqtt_send_q: asyncio.Queue
):
kasa = run_state.kasas.get(kasa_emeter.name)
if not kasa:
logger.warning(
f"Unable to find device with name {kasa_emeter.name}. Ignoring kasa emeter event"
)
return
topic = f"{kasa.topic}/emeter"
payload = kasa_emeter.emeter_status
payload = payload.replace('<', '')
payload = payload.replace('>', '')
logger.info(
f"Kasa emeter event requesting mqtt for {kasa_emeter.name} to publish"
f" {topic} as {payload}"
)
await mqtt_send_q.put(MqttMsgEvent(topic=topic, payload=payload))

myList = payload.split()
print(myList)

for item in myList:
    print( item )
    topic = f"{kasa.topic}/emeter/" + item.split('=')[0]
    print( 'topic =' + topic)
    payload =  item.partition("=")[2]
    await mqtt_send_q.put(MqttMsgEvent(topic=topic, payload=payload))

`

@flavio-fernandes
Copy link
Owner

flavio-fernandes commented Oct 20, 2023

I have tried to use the emeter output, but it has a couple of issues:

* it is surrounded by <>

* all the different parameters are within a single payload

I have edited the code to remove the <> send multiple messages. Can this be incorporated in the standard code?

Of course, @gck303 ! Do you want to make a pull request? Otherwise, I will make these changes for you in the near future.

Pushing changes soon. :)

flavio-fernandes pushed a commit that referenced this issue Oct 21, 2023
Values of emeter are also published individually.

Example:
    /dehumidifier/switch/emeter : <EmeterStatus power=3.14 voltage=122.049119 current=0.1256 total=51.493>
    /dehumidifier/switch/emeter/power : 3.14          <-- new
    /dehumidifier/switch/emeter/voltage : 122.049119  <-- new
    /dehumidifier/switch/emeter/current : 0.1256      <-- new
    /dehumidifier/switch/emeter/total : 51.493        <-- new

Fixes: #10
Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
flavio-fernandes added a commit that referenced this issue Oct 21, 2023
Values of emeter are also published individually.

Example:
    /dehumidifier/switch/emeter : <EmeterStatus power=3.14 voltage=122.049119 current=0.1256 total=51.493>
    /dehumidifier/switch/emeter/power : 3.14          <-- new
    /dehumidifier/switch/emeter/voltage : 122.049119  <-- new
    /dehumidifier/switch/emeter/current : 0.1256      <-- new
    /dehumidifier/switch/emeter/total : 51.493        <-- new

Fixes: #10

Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Co-authored-by: Your Name <you@example.com>
@flavio-fernandes flavio-fernandes self-assigned this Oct 21, 2023
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 a pull request may close this issue.

2 participants