lpgera / dirigera

An unofficial TypeScript client library for IKEA's DIRIGERA smart home hub
https://www.npmjs.com/package/dirigera
MIT License
56 stars 2 forks source link

Energy consumption measuring support [INSPELNING] #10

Closed kevin-wijnen closed 1 month ago

kevin-wijnen commented 1 month ago

Background

As of yesterday, IKEA launched the INSPELNING plug (in the United States, and also France) which is capable of turning its powering device(s) on/off but also measuring their energy consumption. It coincides with IKEA's earlier announcement to support end users with energy consumption readings through their own proprietary mobile apps.

Feature Request

Is it possible to add support for energy consumption readings originating from the INSPELNING, to allow for outputting said data to use it in other tools?

The outlet code might provide base support for controlling the state of plugged in devices, but the energy consumption readings need to be added in to fully support the new released plug.

Although a quick scan through the documentation did not make it clear to me how to contribute it, I'd be willing to help developing support for it once the product is also launched where I do live.

lpgera commented 1 month ago

Hey @kevin-wijnen!

Thanks for opening this issue! I've heard the news yesterday and I'd love to add energy consumption monitoring support to the library, but the INSPELNING plugs are not available here in my country yet, and I couldn't even find a planned release date. 😢

If you, or anybody else reading this issue could create a JSON dump of their system and post the relevant part showing the new device here, that'd be a huge help to get the development going.

kevin-wijnen commented 1 month ago

Hey @lpgera 👏!

Thanks for the fast response - yeah I am waiting for the INSPELNING plugs to get an European release. Looking at the initial (public) announcement/press release in May, it looks like they moved up the release from October to September. So I would assume we'll get them in Europe sooner than later. 👀 EDIT: Seems like France also has them available.

Thanks for pointing me to the dump section of the README - seems like I skipped that part during my quick scan. Hopefully someone sooner or later will be able to help. Count on my testing/support once I can order them myself.

kevin-wijnen commented 1 month ago

Wanted to give a heads up: apparently the INSPELNING should be unofficially available in some countries through the physical stores, looking at https://github.com/Koenkk/zigbee2mqtt/issues/23961.

There's also some information, possibly usable for direct implementation.

kevin-wijnen commented 1 month ago

Another couple updates:

  1. A Python library for the Dirigera had a pull request merged recently, which does provide some dumpoed JSON data originating from the smart plug that could be used for implementation for this TypeScript library as well.
  2. In case we do prefer an own data dumping through the project's tools, I ordered the plugs earlier this week as they became available in the Netherlands this Wednesday. Although I would receive it within the first week of October. This is also really neat for actual testing any implementation with this library.
lpgera commented 1 month ago

Thanks for all the info! The dump from that other library's PR is definitely useful and I can get started with adding the new attributes based on that one.

I'll also likely need to rely on you to test the changes when I get there, because there's still no news about the device in Switzerland.

kevin-wijnen commented 1 month ago

Thanks for all the info! The dump from that other library's PR is definitely useful and I can get started with adding the new attributes based on that one.

Forgot to add this, but when a Zigbee project started implementing it, there were some spotted issues with the measured values. Not sure if they showed up in the Python library, but might be worth knowing when someone gets to testing.

I'll also likely need to rely on you to test the changes when I get there, because there's still no news about the device in Switzerland.

No worries, I'll get to testing it once I get my order in. :+1:

lpgera commented 1 month ago

I looked through all the Inspelning info I could find, including the issues you linked, and implemented the support for the new plug type in https://github.com/lpgera/dirigera/commit/667ede0c7652941313d667b8d6f3484fec98a209. (Not published as a new version as of yet.)

These are the new device attributes which are going to be available:

  startUpCurrentLevel: number
  currentActivePower: number
  energyConsumedAtLastReset: number
  currentAmps: number
  currentVoltage: number
  timeOfLastEnergyReset: string
  totalEnergyConsumed: number
  totalEnergyConsumedLastUpdated: string
  childLock: boolean
  statusLight: boolean

And I added the following new outlet device methods to the lib:

await client.outlet.setStatusLight({
  id: 'YOUR_DEVICE_ID',
  statusLight: false,
})

await client.outlet.setChildLock({
  id: 'YOUR_DEVICE_ID',
  childLock: true,
})

I have no real world info about the capability of switching the status light on or off, or whether there really is a child lock feature on this device, but the JSON dumps suggest that these should work. 🤞

There's one more feature which I couldn't decipher yet. According to the JSON dumps, the device is capable of receiving the energyConsumedAtLastReset property, but I don't understand what kind of input it accepts and what it actually does.

kevin-wijnen commented 1 month ago

Update

Seems like IKEA went from "in stock" (when I ordered) to "out of stock" (auto-cancelling my order) to "limited to large orders" (referring to when they deliver by truck for furniture). 😵‍💫

So I can't test it soon, sadly. I will keep this issue up-to-date once I can actually start testing, or when the plug should be available in Switzerland.

kevin-wijnen commented 1 month ago

Oh hah, I just checked IKEA and it seems to be available for Swiss customers @lpgera!

lpgera commented 1 month ago

Oh hah, I just checked IKEA and it seems to be available for Swiss customers @lpgera!

Huge thanks for the ping, I managed to buy one today.

Support has landed in version 1.1.0 just now!

Closing the issue, but feel free to continue posting questions here, or just open a new one if you find any bugs.

stil commented 2 weeks ago

Is it documented how child lock works? I'm looking for a method to prevent the plug from turning off, either from the app or with the physical button.

lpgera commented 2 weeks ago

Is it documented how child lock works?

What I've seen so far is that if you enable the child lock, it disables the physical button. You can still switch the plug using other methods like from the phone app.

Please keep in mind that I've not found any mention of the child lock in the official user manual or in the phone app, so I cannot guarantee that what works with this library now will keep working the same way in the long term.