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

Is it possible to change channel's names through the API? #50

Open
sol0999 opened this issue Apr 25, 2023 · 7 comments
Open

Is it possible to change channel's names through the API? #50

sol0999 opened this issue Apr 25, 2023 · 7 comments

Comments

@sol0999
Copy link

sol0999 commented Apr 25, 2023

No description provided.

@magico13
Copy link
Owner

If you can do it in the app then there's an API call for it. I don't think that's exposed in this library yet since this is mostly intended for reading out data and turning things on and off, management of that sort of info seems manual enough that I figured you'd do it in the app. May I ask what your use case is that you want to change the names through the API?

@sol0999
Copy link
Author

sol0999 commented Apr 25, 2023

I've been looking for the API call for it for some time now and I thought I should ask. I'd like to have pre-set names for it and do it via a script instead of accessing the webpage.

@magico13
Copy link
Owner

v0.17.0 which I just released has a method def update_channel(self, channel: VueDeviceChannel) -> VueDeviceChannel: that takes in whatever current VueDeviceChannel you want to give it. So you can do something like this to get a particular channel on a device, change the name, then save that change. Let me know if that works for your use-case. That's pretty much all the app is doing.

import pyemvue
vue = pyemvue.PyEmVue()
vue.login( token_storage_file='keys.json')
devices = vue.get_devices()
# find the device with gid 1234 and the channel with channel_num 8
device = next((d for d in devices if d.device_gid == 1234), None)
channel = next((c for c in device.channels if c.channel_num == '8'), None)
# change the name to the current time
channel.name = datetime.now().strftime('%H:%M:%S')
# update the channel
channel = vue.update_channel(channel)

@sol0999
Copy link
Author

sol0999 commented Apr 26, 2023

Perfect! vue.update_channel works. Thank you!

Would the renaming of the name of the monitor, multiplier and nesting under other devices be relatively easy to implement as well?

@magico13
Copy link
Owner

I can look into those other endpoints too but that might not be something I can get to tonight. The multiplier should already be on the channel so that should just work with that new method. Changing the device name and how it's nested will likely be a separate call but seems like it shouldn't be difficult assuming it's just a PUT with the whole object like the channel was.

@sol0999
Copy link
Author

sol0999 commented Apr 26, 2023

Sounds good, thank you!

@jhershbe
Copy link

The multiplier should already be on the channel so that should just work with that new method.

I see the multiplier in the channel info, but it seems to be wrong. It is always showing as 1.0 for me.

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

No branches or pull requests

3 participants