#Thread datastore add via service call

1 messages · Page 1 of 1 (latest)

distant seal
#

Starting another thread about Thread because we all are big fans of Thread threads

#

Oh I can literally just reference the websocket API, duh

unique python
#

yeah, if this was a service call you should totally just call the wrapper

distant seal
#

Any preference on whether I hardcode the "source" to "service_call" or similar, or make it user-changeable?

unique python
#

hard code it, i think if this ends up upstream its probs going to be turned into a WS API and added to the thread panel

#

at which point it will probably be "user"

distant seal
#

I mean all I'm really doing is adding services.yaml and an async_register_admin_service call. The WS API call already exists

unique python
#

ah yeah, duh

#

someone just needs to add a modal to the thread oabel ten

neon juniper
#

Oh so this doesn’t even require a PR? It’s just some fun yaml stuff? That’s awesome

unique python
#

no no, there is code, just not much

distant seal
#

So is there a way to directly async_register_admin_service to call dataset_store.async_add_dataset without making basically a shim that takes in a ServiceCall object, extracts the parameters from it, and calls that function?

#

The register service call says it accepts an awaitable function if I'm reading the type annotation correctly. Still not used to that feature of py3k

#

Yeah I can't grok that right now for some reason, so shim it is

distant seal
#

Gonna see if it works tho

neon juniper
#

slick! happy to test if you have some code to send over

do you have to enter the TLV? still not sure how to generate that from the base info

distant seal
#

You do have to enter the TLV. Another guy also just asked for a script I made to pack Thread info into TLV (which I also only lightly tested lol) so lemme find that too

#

You'll need to modify the python files for the thread component, which is going to vary based on how you have HA running

neon juniper
#

Another guy also just asked for a script I made to pack
I think that ws me haha

distant seal
#

Oh it was

neon juniper
#

🙈

distant seal
#

I think some of my double quotes got converted into fancy ones

#

Yep, fixed

neon juniper
#

thanks! is the channel not necessary?

distant seal
#

Shouldn't be. Thread spec says it'll search across channels, at least during the commissioning. I don't think it'll find a new channel after it has already joined, though. I ran into that issue. It seems to just start up the Thread network on the channel it previously knew.

neon juniper
#

hm so maybe worth adding the channel to be safe?

distant seal
#

Meh, KISS. If it works as it then all the better

#

You'll be the first one to try all this together

#

So if it doesn't we'll go from there

#

I'm grabbing a bulb to test with myself

neon juniper
#

nice - im gonna just do a custom integraiton instead of messing with the actual python code

#

hm having issues applying the patch - did you base off of dev / 2023.3.b1 ?

unique python
#

You know we could just make a script that calls the web socket api outside of HA then you don’t need to patch HA

neon juniper
#

just manually applied the patch and uploaded as a custom-component

distant seal
#

And it'd be nice to get it upstream

neon juniper
distant seal
#

Yup

#

extpanid should be 8

#

I mean yeah just look at the sample data

#

I also updated that gist to add a delete service since I'm playing around

neon juniper
#

there might be something missing in your gist?

the new one includes stuff for deleting in services.yaml, but the old one didn’t include anything for adding

neon juniper
#

yeah i see that in the init.py but no corresponding line in services.yaml

distant seal
#

oh huh it got cut off

neon juniper
#

yeah no wories haha was confused why it wasn’t showing in my services, but your delete stuff gave me the hint 🙂

distant seal
#

fixd

#

Although the channel /shouldn't/ be required, I think HA is expecting either it or some other data:

AttributeError: 'NoneType' object has no attribute 'to_bytes'

#

Oh yep decoded.channel.to_bytes(1, byteorder="little")),

#

Now to find the Thread whitepaper that had the TLV format...

neon juniper
#

channel seems to be 0

distant seal
#

hm. that parser allows for arbitrary length of each field. i feel like that wasn't the case with OTBR/reference Thread

neon juniper
#

but they’re also not lining up with your python script?

#

(but maybe its a bytes vs hex difference?)

distant seal
#

Are they not? ExtPanID is 8, Key is 0x10 = 16

#

Network name is calculated

#

typedef uint32_t otChannelMask

neon juniper
#

oh i think i was just doing the conversion wrong, sorry!

distant seal
#

Updated gist should work

#

My actual OTBR is giving me 00000b for channel 11 though. Wat

#

I think it might be working now, because my OTBR topology page is having a stroke

#

Which is what it usually does when a new device is joining

#

It worked!

#

Aw no reaction gifs

neon juniper
#

hahaha sorry was grabbing lunch!

#

this is awesome

#

smart blinds are provisioned on thread now, awesome!

distant seal
#

Woo!

unique python
#

I’ll ping the guys working on the thread panel about this and see if we can get something added to there

neon juniper
#

Feels like you could roll in the python tlv script too - maybe as a separate service with multiple params

unique python
#

What blinds btw?

neon juniper
#

smartwings nano - got in on the indigogo earlier

unique python
#

And using homekit controller?

neon juniper
#

yup

unique python
#

And smart things br?

#

First time hkc used with those blinds and that BR, so trying to keep track

neon juniper
#

yup

#

I paired the blinds with HA via Bluetooth first as a homekit device, plugged in my old SmartThings Hub v3 and got it updated to the latest matter-compatible firmware (which includes a Thread BR), used @distant seal ’s cool stuff to import my smartthings thread credentials into HA, and then provisioned the blinds onto the thread network!

#

not sure how this all will shake out long-term if i get other thread border routers, but working for now 🙂

distant seal
unique python
#

Depends!

#

If they think it’s too advanced they might not want it in Ui

#

I think it’s a good fit tho

distant seal
#

Raw TLV in the UI is probably a no-go, but a simple "Enter your Network/Key/etc." would be pretty friendly

unique python
#

Yeah

neon juniper
#

just need to make it more user-friendly with things like padding the PAN if it isn’t 4-digits, doublechecking lengths, etc

distant seal
#

Or the PR can be closed by balloob himself lol

#

O wel

unique python
#

He thinks it already exists isn’t the Ui but I can’t find it

distant seal
#

And here I spent all that time writing 5 lines of code! :p

neon juniper
#

thank you for your service!