This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.
Closed

Copy flows

Sometime I want to copy a flow when a second flow is in a lot of ways like the old one. This so I could the edit the second flow without adding 10 items first.

Comments

  • I have copied flows  using powershell scripts. 
    Export all your flows and import one as copy.
    The app is pending approval,  will make a example this evening,
    Apple is published here.
    https://github.com/Dijker/nu.dijker.HomeyPSCLI 

    If you are not afraid of using Powershell command line on Windows , go ahead!

    With my powershell module should be two commands.
  • Actually already done it:

    If you have my module installed:
    PS C:\Homey\PS> Connect-Homey -IP 10.1.13.107 -ExportPath C:\Homey\PS\Backup\ -Bearer "bdc38b******"
    56a***********************d16.homeylocal.com ICMP Response OK
    56a***********************d16.homeylocal.com HTTP Response OK
    Homey version 0.10.3
    PS C:\Homey\PS> Export-HomeyConfig
    PS C:\Homey\PS> Import-HomeyFlow  -JSONFile .\Backup\Folders\ScreenAutoDown-8b40cf8c-cc7f-4f1e-8365-00f65bb203fc-v0.10.3 -20161009171258.json -NewFlowID
    Warning: Flow does not Exists! use -NewFlowID
    (ignore the Warning, I will fix it in the Next Release ;-)  First App Aproval for my initial Release 0.0.3 ;-) )
    In the Picture I omitted the -Bearer for the Connect-Homey as it is already configured on my system.

    You can also specify -RestoreToRoot to have the copy not in the same folder,
    or specify -OverwriteFlow for Import-HomeyFlow if you have done a good export and F*ck-up the flow and want to restore your previous export. 
  • How can I download the PowerShell Module from Homey?
  • SergeR said:
    How can I download the PowerShell Module from Homey?
    The app is pending approval in the app store, the link abovery to the github has  the source.
    Download  the zip and extract the HomePSCLI folder with the to files to your local modules directory.  
    Have phun!
  • SergeR said:
    How can I download the PowerShell Module from Homey?
    The app is pending approval in the app store, the link abovery to the github has  the source.
    Download  the zip and extract the HomePSCLI folder with the to files to your local modules directory.  
    Have phun!
    An app to create a download and is updateable from the store. How clever!
  • edited October 2016
    That PowerShell module is amazing - thanks @GeurtDijker!

    Just one quick question, Export-HomeyConfig works (I can see flows being exported to the right folder), but the cmdlet ends with this:

    The script failed due to call depth overflow.
        + CategoryInfo          : InvalidOperation: (0:Int32) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : CallDepthOverflow

    Is that important?
  • MatjaLipuMatjaLipu Member
    edited October 2016
    @GeurtDijker app looks amazing. However I am using mac :)

    Basic idea has a lot in common with Candy app. What do you think to move all Homey communication to Candy app, consolidate requests/responses and expose it in api.js?

    Then if internal functionality changes (like in 0.10) all apps depending on api would work without requiring changes..
  • I can even imagine Homey creates a zip and imports one without the need of powershell :smile: 
  • That PowerShell module is amazing - thanks @GeurtDijker!

    Just one quick question, Export-HomeyConfig works (I can see flows being exported to the right folder), but the cmdlet ends with this:
    [...]
    Is that important?

    Yes, Thanks for reporting! 
    Was it only during the first Export-HomeyConfig? or also the second  or third time wile keeping the first export and just running again. 
    Was it the App version from the App Store or an older direct from the Github?
    Do you have a full folder structure with 4 foders below the export directory and 4 files (and possibly many  folders and files below them)? like this:

    Didn't see it here, I will have an look. Thanks for reporting!
  • I can even imagine Homey creates a zip and imports one without the need of powershell :smile: 
    I would love it when Athom or maybe a better developer than me makes a decent backup app or core function. of course a singel button / singel file with the option to restore it complete or only parts (singel  flow/ device etc...)
    But for now they work on stability and other top priorities (Bluetooth, Apps like IFTTT, etc) And I think that is OK!

    For now I fill my time and do my things with Powershell.
    I know it is far from what I want to learn to  Emiles mother ;-) 

    But for now: Enjoy  Powershell if you  like...  
  • MatjaLipu said:
    @GeurtDijker app looks amazing. However I am using mac :)

    Basic idea has a lot in common with Candy app. What do you think to move all Homey communication to Candy app, consolidate requests/responses and expose it in api.js?

    Then if internal functionality changes (like in 0.10) all apps depending on api would work without requiring changes..
    Hi @MatjaLipu ;
    The good News for you: PowerShell is open Source !!! Get it om the Mac ;-)
    https://blogs.msdn.microsoft.com/powershell/2016/08/18/powershell-on-linux-and-open-source-2/ 

    .... Just kidding, 
    I know Powershell is not for everyone,
    If you can do things in Candy App inspired by my app.... Great ! do IT! no problems. (Copy a flow? )
    I will still try to keep up with the api' s and where possible I want to use Apis from apps. 
    fe, for the bug that some variables from Better Logic disappears I created a incremental  import/restore ;-) 
    I will make an example of that also in my App Thread!

    And Yes, If you expose an api to do things easier .... I like to integrate them in my Powershell Module! 

    Thanks for your support!

    I will be mostly offline  a couple of days, bat after that we will have contact here and on slack? 
  • That PowerShell module is amazing - thanks @GeurtDijker!

    Just one quick question, Export-HomeyConfig works (I can see flows being exported to the right folder), but the cmdlet ends with this:
    [...]
    Is that important?

    Yes, Thanks for reporting! 
    Was it only during the first Export-HomeyConfig? or also the second  or third time wile keeping the first export and just running again. 
    Was it the App version from the App Store or an older direct from the Github?
    Do you have a full folder structure with 4 foders below the export directory and 4 files (and possibly many  folders and files below them)? like this:

    Didn't see it here, I will have an look. Thanks for reporting!
    Yes, that only happens during Export-HomeyConfig. When I re-run the cmdlet, same thing happens, and this is what I find in the export folder (one additional Folders JSON file in the root for every time I run it):

    The app was installed from the store (two days ago)

  • That PowerShell module is amazing - thanks @GeurtDijker!

    Just one quick question, Export-HomeyConfig works (I can see flows being exported to the right folder), but the cmdlet ends with this:
    [...]
    Is that important?

    Yes, Thanks for reporting! 

    [...]

    Yes, that only happens during Export-HomeyConfig. When I re-run the cmdlet, same thing happens, and this is what I find in the export folder (one additional Folders JSON file in the root for every time I run it):

    The app was installed from the store (two days ago)

    Ok, Thanks.... Thats not OK ;-)
    You only get one file each time and it stops with that error.....
    Are all Flows exported to the folders below your folder named "Flows" ?
    I guess the export of Flows in 1 flow per file fails.

    In your other example you use $allFlows = Get-HomeyFlows
    I guess without problems?

    Can you test the following:

    test Export-HomeyConfig again, as that fails after that in the same session, 
    test the following command:
        $_FlowsJSON = Export-HomeyFlows 

    I guess that fails again....
    After creating the Folders*.json I call
        $_FlowsJSON = Export-HomeyFlows 

    Maybe Your Homey contains some for me unexpected info in the Flows you created where Powershell gets looping. 
    Can you change Line 525  in the module from
        $_FlowsJSON = Export-HomeyFlows 
    to $_FlowsJSON = Get-HomeyFlows
    Next command in the moddule is 
    $_FlowsJSON | ConvertTo-Json -depth 99 | Out-File -FilePath "$_HomeysExportPath\Flows-v$_HomeyVersion-$_ExportDTSt.json" 

    after that you should be able te run Export-HomeyConfig without problems....
    Can you send met the latest Flows-*.json and Folders*.json ?
    Maybe there are flows in non-existent folders...
    I prefer to get them at Slack as an attachment in my PM. 
  • MatjaLipu said:
    @GeurtDijker app looks amazing. However I am using mac :)

    Basic idea has a lot in common with Candy app. What do you think to move all Homey communication to Candy app, consolidate requests/responses and expose it in api.js?

    Then if internal functionality changes (like in 0.10) all apps depending on api would work without requiring changes..
    Hi @MatjaLipu ;
    The good News for you: PowerShell is open Source !!! Get it om the Mac ;-)
    https://blogs.msdn.microsoft.com/powershell/2016/08/18/powershell-on-linux-and-open-source-2/ 

    .... Just kidding, 
    I know Powershell is not for everyone,
    If you can do things in Candy App inspired by my app.... Great ! do IT! no problems. (Copy a flow? )
    I will still try to keep up with the api' s and where possible I want to use Apis from apps. 
    fe, for the bug that some variables from Better Logic disappears I created a incremental  import/restore ;-) 
    I will make an example of that also in my App Thread!

    And Yes, If you expose an api to do things easier .... I like to integrate them in my Powershell Module! 

    Thanks for your support!

    I will be mostly offline  a couple of days, bat after that we will have contact here and on slack? 
    I think what MatjaLipu is trying to say is that the two apps should/could be merged?
This discussion has been closed.