-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Lucid migration #91
Lucid migration #91
Conversation
Thanks Scott. I will dive into this as soon as you have finished and I will answer to each comment that you've made of course. Encountered new problems using my Windows git client on a SSH mounted shared directory on my linux server. I think I'll have to give that up. Maybe it was doomed to malfunction from start. I will have to figure out a better setup and a better workflow and do all the git stuff from the command line in linux instead. Please let me know when you think it's a good time for me to start testing. |
@openhab-5iver A few questions... Should I test this in OH2.4 stable? I was thinking that the best test would be to use all my current scripts including ideAlarm. Do we really need a separate branch for ideAlarm or can we try to incorporate it into the Lucid branch? What would you prefer? |
Unless I convert it to a string I'll get the following error:
Using code
Even though |
Yes. Anything <= S1524. Builds between S1524 and S1566 had a bug that broke scripted automation and was resolved in S1566. But that build also included the ESH reintegration, where some packages were renamed and requires changes to the libraries. Once lucid is migrated, I will get some releases built so that people can easily pick a version of the libraries to suit their OH version.
These can be merged. I'll do that today.
To use sendCommand where the command is not a String, you need to use an Item. Similar for postUpdate.
https://www.openhab.org/docs/configuration/jsr223.html#events-operations |
Try a samba mount and VS Code. This works well for me for quick stuff (but I use Fedora for my OS... client and server), but I've also started using Eclipse with the Jython stuff. I has it's own quirks, but EGit has some benefits, particularly the interactive rebase. |
Thanks I will try to set up a Samba mount tomorrow on my Ubuntu server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things I think should be removed:
- I don't think configuration.postUpdate and sendCommand should be included, since they are converting to string, but that is not always needed and may cause issues
Thanks for your explanation. I agree. But for backward compatibility and to prevent creating a breaking change, what if we just modify them like this:
def sendCommand(item, newValue):
'''
Sends a command to an item regerdless of it's current state
The item can be passed as an OH item type or by using the item's name (string)
'''
events.sendCommand((itemRegistry.getItem(item) if isinstance(item, basestring) else item), newValue)
def postUpdate(item, newValue):
'''
Posts an update to an item regerdless of it's current state
The item can be passed as an OH item type or by using the item's name (string)
'''
events.postUpdate((itemRegistry.getItem(item) if isinstance(item, basestring) else item), newValue)
About the postUpdateCheckFirst functions, what about if we change to something like this:
if sendACommand:
log.debug('New sendCommand value for '+itemName+' is '+str(newValue))
events.sendCommand(item, newValue)
else:
log.debug('New postUpdate value for '+itemName+' is '+str(newValue))
events.postUpdate(item, newValue)
I'll submit additional reviews (I hope that's possible, well, I'll find out) regarding the other comments.
EDIT: Code updated
I think that will resolve the issue, but I'm not clear on why you couldn't just send what is received. My issue though, is that I question the need for this in the helper libraries at all, especially in core. The only convenience provided is to not have to type It's really not a big concern for me though, so I left them in! |
Signed-off-by: Scott Rushworth <[email protected]>
Have we now reached the point where it's time for me to start testing? |
Yes... ready for initial smoke tests, but expect errors! I've tested some of the scripts for proper formatting, but nothing functional. It will be a lot easier for people who were already using the libraries to do the testing. It may be easier to correct errors after it is merged, but it would be nice to get as much as we can fixed now. |
Thanks a bunch! The github pull requests extension in VSC is new to me and there is a learning threshold. I'll try to get used working with it and I'll see if I can start using code commenting as well. One thing that happens if I checkout the pr/openhab-5iver/91* PR locally is that some recent changes in master are not there. (Missing .gitignore file and more...) I'll have to study how to handle that I guess or maybe the pull request can be rebased with master? |
I'll try to get it synced up, but you could just download https://github.com/openhab-5iver/openhab2-jython/tree/lucid-migration and copy the files you need. |
I'm still a NOOB when it comes to github. I managed to get it synced locally but struggeled with merging conflicts due to differences regarding the "But-How-Do-I.md" whether it was renamed or deleted and git complained that I had to reolve that and commit before merge is possible. Anyway I got passed it but I probably messed up my local repo a bit. I might want to re-clone the original repo when/if you make the PR up to date with master. I added a note in the getting started document about the need of creating a config file.
I'm still trying to figure out a good workflow so that we don't have to make every single change 3 times. (I change, I write a comment here, you edit the original files). Maybe I need a web repo fork as an intermediate so that I can push my change proposals. Yeah, I think I will try to set that up tomorrow. EDIT: I've now made forked openhab-5iver/openhab2-jython to a personal web repo and I sucessfylly merged the master branch into the lucid-migration branch. That worked well. After that I cloned my repo to my local server, checked out the lucid-migration branch (which is now up to date) and I start to push my changes to it. I guess that when I'm finished I can make a PR to your repo openhab-5iver/openhab2-jython Do you think that will be a good way forward? I have one question though. Previously I could change the logging level at rule level which I found very convenient.
DEBUG is no longer in the global scope and even if I try to set the logging level for a rule it doesn't seem to make any difference. I tried this but it didn't work out:
OK, today no progress for me really, just learning ... EDIT: In lucid (rules.py) I had the following code:
and
I added this wrapper function into lucid trying to make just small things easier for people who like to get started scripting without prior experience. Is it something we'd like to retain or what do you think? |
Yes... that was one of the options. 😄 I'll also be getting the gitignore change synced.
Can you just change this...
to
Or am I missing something? I have set the LOG_PREFIX to "jsr223.jython", so be sure to set the logging level for this to at least DEBUG. You could
... which is what the Karaf console command is adding. I also setup two appenders... one for rules and one for core. I'll be sure to add some explanation for logging in the doc.
All of this (and more) is added to the context through the "default" scriptExtension, which is added to all scripts...
... so I did not see the need for them (number 5 in the Things Removed section of OP). Are you not able to access them in your scripts?! |
OK... git fought hard, but I finally got things synced. The commits look weird, but I'll squash before the merge. |
EDIT: Logging levels worked as before. I removed that part from this text. I haven't tested a lot but the Cheers! EDIT: I'm setting up a copy of my home environment for testing purposes. I'll have access to all my familiar OH Items etc that I'm used to and I'll be able to test the migration better. It takes some time though but I feel there is some progress. ;) |
I'm a little confused... is this not an issue? |
Signed-off-by: Scott Rushworth <[email protected]>
Merge branch 'lucid-migration' of https://github.com/openhab-5iver/openhab2-jython into lucid-migration Signed-off-by: Scott Rushworth [email protected]
Signed-off-by: Scott Rushworth <[email protected]>
* Added instruction for creation of configuration file. * Changes * Changes * Various fixes * Finished stage 1 * getLastUpdate removed PersistenceExtension to be supplied as a parameter * Requested changes first round * Requested changes round two * requested changes round three * Adding custom date formatting for weatherUploader * Adding custom date formatting for ideAlarm * Revert changes to date.py made in commit e46eaf4 * Move customDateTimeFormats to proper example configuration files * Moving pushover configuration to ideAlarm example config file
Signed-off-by: Scott Rushworth <[email protected]>
@besynnerlig, I've made some more changes that will need your review and synced up with master to pick up the core.date fixes. I did not include the rename of the /automation/jsr223/core/. I will do that right after this PR merged, so just rename your core directory to 000_core for testing. |
Thanks. I'll have a look at it tomorrow (monday morning). |
My web repo branch is 23 commits ahead, 9 commits behind openhab-5iver:lucid-migration. I have no idea how to re-sync. I guess the easiest would be to discard my repo on my local machine and clone yours again. I think I'll do just that. |
That would do it, but this should work too (do this from inside the git directory of your clone)...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have finished testing. I found just a couple of problems that I'll submit to your personal repo as a PR.
When you feel that the time is right, please let me know and I'll make a more extensive test. Then I will migrate my production site from OH 2.3 to OH 2.5M1. That will include migrating all my jython scripts.
EDIT: Made PR 5iver#2
Community/WeatherStationUploader/automation/lib/python/configuration.py.example
Show resolved
Hide resolved
Community/ideAlarm/automation/lib/python/community/idealarm/__init__.py
Outdated
Show resolved
Hide resolved
Community/ClickaTell/automation/lib/python/community/clickatell/__init__.py
Outdated
Show resolved
Hide resolved
Signed-off-by: Scott Rushworth [email protected]
After those last two fixes, I think we are ready to merge this. If we find bugs after the merge, it will be a little more effort to update both branches, but not too much. After the merge, I'll setup a branch to store the <=2.5M1 code, update master to >2.5M1, and get on with the repo renaming! |
Signed-off-by: Scott Rushworth [email protected]
Signed-off-by: Scott Rushworth [email protected]
@besynnerlig, the last two fixes are merged. Are you ready to approve the PR? [DONE] |
Signed-off-by: Scott Rushworth [email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and approved.
The way the repo is currently setup, the person that created the PR can't approve their own PR, and an approval is required before it can be merged. Being an admin, I can do anything, but to be official about it, you should start another review and select 'approve changes'. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed and approved
I'm not sure. Am I approving changes in the wrong place? |
No... you don't have write privileges... I'll need to rethink that. I'll waive the magic wand... |
Round 3 of migration. This should wrap up the bulk of the changes, and we are ready for testing. ideAlarm and weatherStationUpdloader are now in my fork. The lucid-migration branch in this repo is behind, so please use my fork for testing. We will also need to discuss/resolve everything below.
Things removed during lucid migration:
Things I think should be removed:
Nothing in core should be using customItemNames. Anything using it can be moved to implementation specific modules in community.core.utils.getLastUpdate should be removed. I'm not clear on the useage, but it appears to require PersistenceExtension to be supplied as a parameter?isActive, isBright, isShady, isDark, isBlack shouild all be moved out of utils and into an implementation specific script or module.Other considerations:
PUSHOVER_DEF_DEV was imported in ideAlarm, but it wasn't used and there was no definition for it.I've migrated weatherStationUploader, but it will not work since it uses wunderground, who have changed their API.I tried something in IdeAlarm.getTriggers(), which wasn't really unecessary but will allow use of the decorators for rule definitions. Definitely needs testing.postUpdateCheckFirst should use TypeParser.parseCommand and TypeParser.parseState.Fixes #51, #52, #53.