PowerShell based cmdlets / Commands

Moderator: Telldus

c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

Sorry for a late reply! I'd love to support that. I guess I just have to upgrade to a znet first :)

Will try to look into it... :)
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

Sure, that looks very straight forward. I haven't had use for that so far, no other reason why it hasn't been created :-)

I'll put it on the ToDo-list!
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

ArneG wrote:What about a set (rename?) devicename cmdlet? Winstick has this features so I think it is in the API...?
Updated the module with Rename-TDDevice now. Also added Get-TDEvent, and up/down actions for Set-TDDevice. I don't have any device supporting that though, so I haven't been able to test that (up/down actions).

I also noticed a bug in Connect-TelldusLive when used with the "-SaveCredential" switch on the first run which is hopefully fixed now. Sorry about that!

If you installed the module from PowerShell Gallery you can simply run "Update-Module Telldus -Force" to get the new version.

The latest version is also always available at:
https://www.powershellgallery.com/packages/Telldus


If you want any other features in this module, feel free to request them here :-)
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

So, with the release of PowerShell 6.0 aka PowerShell Core, I wanted to revisit this project a bit. (see: https://blogs.msdn.microsoft.com/powers ... supported/)

The goal is to enable cross platform support (PowerShell core runs on Windows, macOS and Linux. Also works on Raspberry Pi 2) which I believe would be quite nice for a module that relates to home automation.

In this process I also wanted to enable OAuth but without the need for all users to get their own individual API keys.

The updated version is now available with a new name. You can get it from:
https://www.powershellgallery.com/packages/AutomaTD

Or by running the following command in PowerShell:
Install-Module AutomaTD

I will allow the old version of the module to still be listed on PowerShell Gallery if anyone needs it, but I really want to encourage you to try the new version which is more officially supported by Telldus (complies better with their APIs, they won't help you with module issues of course ;) ), and it also contains a few bugfixes already that the old version had.

All future development will go into the new version.

Edit: Removed information about the pre-release versions
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

ArneG wrote: Thu Jan 18, 2018 11:08 am A few other tasks that we have to log on to Teldus Live manually to perform would be nice to be able to do via the CMDLet:
Turn on/off the Telldus live's 'store history'-function for sensors.
Set the Ignore/Show switch for devices/sensors
Implemented in the new module (Set-TDSensor)! Also added Get-TDClient. Get-TDSensor now returns the latest value of the sensors directly (don't need to call Get-TDSensorData), also added an option to fetch hidden/ignored sensors. Set-TDDevice have "stop"-support now.

Just fetch/update to the latest version on PowerShell Gallery.

Edit: I'll also look into adding functionality for updating device settings (like hide/show etc.)
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

hmm, odd. Just tried it on one of my sensors and it worked fine for me.

You ran something like:
Set-TDSensor -DeviceID 123456 -IgnoreSensor $true

or?
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

That is really weird, when I run it against one of my sensors I get a success status back and the sensor gets ignored.

Not sure it's related... But Telldus returns a "editable" property for all sensors, is that set to True or False for the sensor you try to ignore?
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

Very odd indeed, not sure what's failing.

I guess the easiest way would be to simply run Get-TDSensor, it returns the "editable" property :-)
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

Alright, not sure what can cause that then.

Does it work if you just check the "Ignored" checkbox through live.telldus.com and hit save? (I know you tried posting it in the URL, just want to make sure you also tried the standard "UI" way :-) )
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

I noticed they are using different api endpoints for this method at api.telldus.com (/setIgnore) and live.telldus.com (/setIgnored).

So maybe that's why the test you did earlier didn't return anything.

If you try this link you might have greater luck:
https://live.telldus.com/sensor/setIgno ... &ignored=0

The module however, is using the endpoint under api.telldus.com, so I'm afraid it doesn't help us much.

I have yet to have that method fail for me though, I've tried it a bunch of times on different sensors and it works every time for me.

Currently have no clue why it wouldn't work for you :(
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

Ah, I see. That definitely explains the issues you were having.

You should know the new module works more or less exactly the same as the old one in the shell (I have myself migrated all of my home automation to it without any changes except for the specified credentials), you can store the credentials (stored locally, encrypted) the same way and not have to re-auth etc.

The main difference is that it is implemented the way that Telldus specifies and will long-term be more reliable. It has way better portability as well since it supports PowerShell core (can run on a raspberry pi etc.).


That said, I agree with the principle of "if it works, don't fix it", and I'm very happy you got a setup that works for you! :D
Masonit
Posts: 79
Joined: Fri Mar 17, 2023 9:45 am

Re: PowerShell based cmdlets / Commands

Post by Masonit »

Hi

Seems like the cmdlets has stopped working. Think it hasen't worked for 10 days now. Connecting works fine. But not for example get-tddevice and get-tdsensor. Any possibility to update cmdlets?

\Masonit
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

huh, weird, they still work fine for me. Are you using the latest module or the old one? (AutomaTD is the new one that should work just fine)

If you're using the new one and it still doesn't work, maybe try to reauth and see if that helps.
Masonit
Posts: 79
Joined: Fri Mar 17, 2023 9:45 am

Re: PowerShell based cmdlets / Commands

Post by Masonit »

Thanks for quick reply. :)

Yes, I saw that there was a new one. I installed AutomaTD 1.1.1. But I have problem connecting. I tried with:

Connect-TelldusLive -SavedCredential , I pasted url in browser and logged in to telldus site and gave permission to AutomaTD. I then came to https://automatd.net and in the url I have oauth_token and oauth_verifier. Is this accesstoken and AccessTokenSecret?

I tried to save accesstoken and AccessTokenSecret to a pscredential. And connect with Connect-TelldusLive -Credential $cred.
No errors but when running get-tddevice I get: "statusCode":500,"errorCode":0,"message":"An error has occurred. For more information, please check the logs

\Masonit
c8h10n4o2
Posts: 86
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PowerShell based cmdlets / Commands

Post by c8h10n4o2 »

hmm... You're right, something is broken with the Connect-TelldusLive cmdlet.

I will try to look into this as soon as I get a chance and update the module to fix it. I'll report back as soon as that is done!
Post Reply