Jump to content

Soft Keypadlinc-like Console from Raspberry Pi


kck

Recommended Posts

@chrisb5 - Glad that worked out.  You asked earlier about making a screen to view sensors, did you make progress with that?  I don't bother having my leak sensors (or door sensors) on a normal screen, but rather use alarms for them.  This gives the advantage of an instant visual clue something is wrong (none of my leak sensors should ever be wet!). 

Something like this in a file named alertLeaksDRC (again name doesn't matter, just include in config.txt):

[Alerts]
        [[Leak Sensor1]]
        Type = NodeChange
        Node = LeakSnsr1-AqBelow-Wet
        Test = NE
        Value = 0
        Invoke = LeakSnsr1
[LeakSnsr1]
        type = Alert
        BackgroundColor = white
        MessageBack = red
        CharColor = black
        Message = Leak Sensor, 1, Got Wet, Under Aqrm
        CharSize = 30, 30, 30,40
        DeferTime = 2 minute
        BlinkTime = 1
        KeyColor = maroon

I have separate alert files for different types of alarms/sensors.  Just makes things easier for administration.

 

Link to comment

Chris:

Yup that error sucked at telling you the location field didn't match.  EVictory ran into the same problem last week.  That's the problem when you are testing your own code - sometimes you just don't make some errors/typos to see how bad the messaging is.  I've fixed (trivial 3 liner) both the TimeTemp and Weather screen creation code to catch this in the future (so at least some future person may thank you).  That fix will go into whenever the next release happens.  Glad Dan could point you in the right direction.

Dan:

After you reported that the explicit python3 didn't work I looked and there is a small starter program "runconsole.py" that decides whether to run beta or stable etc. and it just used "python" to start the real script.  I can edit that to use python3 for the next release but in the meantime you can just edit the one line that does the subprocess.Popen to use python3 and I think that will do it for you. (ETA: also edit the 1st line that indicates the script interpreter for runconsole itself to say python3)  Way back when I started this I didn't know anything about Python deployment or I would have used something like the venv mechanism to compartmentalize the console.  Unfortunately it would seem to be a lot of work to get there from here at this point.  You might look to see whether the other stuff you are running can be installed with venv - that would let it set its own libraries and interpreter versions.

Link to comment

@Screw Loose Dan Thanks! I was just reading through the docs and sample configs trying to figure that out - but I agree the alert seems to be a better representation for those sensors.

I setup my leak sensors and smoke/CO2 sensors based on your examples and they seem to be working. I even had one of my sensors tripped and got to see what the alert screen looks like - very nice!

Not sure how to pull the temp from my AEOTEC sensors though (for display in my screens). All the values show up in the ISY console (i.e. it knows how to parse them and I can use the sensor values in conditions in programs via built-in pulldowns) but (and I"m running v4.7.3) I don't see any option to set a variable to the value from a sensor/device. 

Also I see that I'm getting lots of the "ISY reported and immediately cleared error for node:" messages in my logs... so I suspect I may also need to select the new beta release to get around that - though I don't know if the SSL ignore-certificate-errors fix got applied there yet?

Link to comment
4 minutes ago, kck said:

Dan:

After you reported that the explicit python3 didn't work I looked and there is a small starter program "runconsole.py" that decides whether to run beta or stable etc. and it just used "python" to start the real script.  I can edit that to use python3 for the next release but in the meantime you can just edit the one line that does the subprocess.Popen to use python3 and I think that will do it for you.  Way back when I started this I didn't know anything about Python deployment or I would have used something like the venv mechanism to compartmentalize the console.  Unfortunately it would seem to be a lot of work to get there from here at this point.  You might look to see whether the other stuff you are running can be installed with venv - that would let it set its own libraries and interpreter versions.

Yeah, don't expend any energy on this. I don't think the package that was trying to use python2 was even needed, it just broke the install of the node server in Polyglot.  I manually uninstalled the offending package (with python temporarily set to python2) and have everything working at the moment.  In another thread I'm asking that developer if the python2 package is even needed.

3 minutes ago, chrisb5 said:

@Screw Loose Dan Thanks! I was just reading through the docs and sample configs trying to figure that out - but I agree the alert seems to be a better representation for those sensors.

I setup my leak sensors and smoke/CO2 sensors based on your examples and they seem to be working. I even had one of my sensors tripped and got to see what the alert screen looks like - very nice!

Not sure how to pull the temp from my AEOTEC sensors though (for display in my screens). All the values show up in the ISY console (i.e. it knows how to parse them and I can use the sensor values in conditions in programs via built-in pulldowns) but (and I"m running v4.7.3) I don't see any option to set a variable to the value from a sensor/device. 

Also I see that I'm getting lots of the "ISY reported and immediately cleared error for node:" messages in my logs... so I suspect I may also need to select the new beta release to get around that - though I don't know if the SSL ignore-certificate-errors fix got applied there yet?

I don't use any ZWave sensors (yet), so I'm not sure how they would appear in the softconsole, but I presumed as regular ISY devices.

Did you upgrade to the latest version, Kevin just released it this morning.  Tap the screen rapidly 5 consecutive times to get to the maintenance screen, then Select Version -> Download release  (this will take a bit, it's downloading the code, mine takes a few minutes) -> Return -> Exit/Restart -> Restart Console.

Link to comment

Chris,

Definitely just get the current stable release.  It has the fix for the report/clear message and your ssl ignore in it.  I can't tell you much about the zwave via ISY stuff.  I do run Zwave but control it via homeassistant and the console also handles homeassistant hubs so that works for me.  If the sensors have an option for reporting via an MQTT broker that would also work pretty easily.  That is how I handle some other sensors that I built (sub $5 temperature/humidity sensors using ESP-01 board and DHT-22 sensor).  The console can parse MQTT messages and extract things like temperature from those.  But I don't have any idea if your sensors have that option.

Kevin

Link to comment

Key color question;

For the basic Insteon (or other ISY supported types) is it possible to configure the standard buttons for each to be something simple like Green if ON and Red if OFF? Either the background color for each button - or if not that just the text (label) color perhaps? Or even the outline color - default seems to be outline in white=ON outline in black=OFF.. ?

Link to comment

Yes.  See the parameters KeyColorOn and KeyColorOff and KeyCharColorOn, KeyCharColorOff, and change wording KeyLabelOn, KeyLabelOff.  Also KeyOffOutlineColor and KeyOnOutlineColor

Link to comment
  • 1 month later...
On 1/7/2019 at 3:00 PM, kck said:

Dan,

The light sensor would be nice - of course it would require some hardware added to the Pi.  Have to think about that as it would be a bit more than some folks would want to tackle.  However, the time based change you can do now pretty much.  All the screen general variables are in the store "System" so in particular the DimLevel is referenced as System:DimLevel.  So I have a couple of alerts defined in my configs that look like:

<snipped code for brevity>

These do the obvious things.  The only issue with them is that since they execute at a specific times so the initial condition after console start will persist until the first time one executes.

If you are running MQTT then you can even do the adjustments via that if you publish the right stuff.  For example, using mosquito you could run the command:


mosquitto_pub -t consoles/rpi-pgaw1/set -m '{"name":"System:DimLevel","value":50}'

To change the brightness of that node right now.  This is handy if you want to quickly experiment with dim levels - just reissue it changing the value.  You could even send this to all your consoles with a single command if you replaced "rpi-pgaw1" in the above with "all".  So it wouldn't be too hard to do more sophisticated changes by running scripts from cron or the like.  Other system variables are also changeable if that's useful.  Do a StoresDump from the debug flags screen and you'll get a file in the Console directory with a full dump of what the stores hold and in principle you could change any of them.  The caveat is that things that impact screen colors and the like may have been already used to build templates and so not have any effect, although I think background colors would change.  I know key colors wouldn't generally change.  Figuring out how to make all those actually take effect dynamically is actually on the longer term todo list so if there are any items that you think would be useful to make sure are actually changeable let me know.

Does this handle your immediate desire?

Kevin

P.S. Going to Antarctica to see the Penguins! :-)

I gave a bit of thought and played around making my screens dim.  While I am using MQTT now for other things, I didn't think it made a lot of sense for this particular application.  I ended up cobbling together an alert script, lightsensor.py (heavily based on the networkhealth.py) and I am using the TSL2561 light sensors (here on Adafruit, cheaper else where).  Currently I have the interval set at 5 seconds and been happy using it that way for the past ~month. 

If anyone is interested, the code and some instructions are here.

@kck - If you want to play around with this, I have a couple spare sensors, I'd gladly send one you way.  Hope you enjoyed your time with the penguins!

 

Link to comment

Cool!  Would you mind if I added it to the standard distribution so it would be generally available?

Everything about Antarctica was fantastic - the most amazing scenery I've ever seen.  You just can't get the sense of grandeur from TV shows - the scale gets lost.  And the penguins are incredibly cute!

Link to comment
5 minutes ago, kck said:

Cool!  Would you mind if I added it to the standard distribution so it would be generally available?

Wouldn't mind in the least!  In fact, I'm sure it will make it easier for me when upgrades happen.  Perhaps link to my Github page for instructions?

I've been doing some other projects with MQTT, but just getting around to getting Sonoff sensors to display on the console.  I have my two consoles connected to a management broker and all that appears to be working (view/clear errors from either console, etc).  And, I can get the softconsole subscribed to the tele topic, but not sure how to config to parses the json.  Perhaps it's obvious and I'm just looking at it wrong?  This would be what some of my sensor topics looks like:

garage/wemos/tele/SENSOR {"Time":"2019-02-19T22:24:36","BME280":{"Temperature":54.2,"Humidity":40.1,"Pressure":1029.6},"PressureUnit":"hPa","TempUnit":"F"}
bedroom/wemos/tele/SENSOR {"Time":"2019-02-19T22:24:43","AM2301":{"Temperature":65.5,"Humidity":45.4},"TempUnit":"F"}

Any help pointing me in the right direction would be appreciated.

Link to comment

OK - I'll stick it in next time I update stuff and point to your GitHub.

Guess I'd better not break the management console reporting stuff now that someone else is using it! :-)

JSON: take a look at the example config pgawmqtt.cfg in the distribution.  The parsing I do is very simplistic.  You should be able to set the Topic = garage/wemos/tele/SENSOR and then json = AM2301:Temperature and TopicType = float which should all get you a store entry at MQTT:XXX assuming you named your MQTT feed "MQTT" (change as needed) and XXX as the name of the entry from the mqtt config.  Basically the flow is that the mqtt section defines a mapping from topic and value (extracted from json if needed) to a store entry that you can then use as you wish.  I do exactly what it looks like you are doing where I have a bunch of ESP-01s with temperature sensors running Tasmota (great contribution from that author!) that report with MQTT packets every minute or two.  Let me know if this doesn't work.

 

 

Link to comment

Ahh...it's all coming together.  Thank you.  I had been focused on the documentation (and code) instead of looking at the examples. <doh>  

Speaking of the documentation, in the usage notes for MQTT commands, it appears to list the function names from the code and not the actual commands.  Which led to some confusion on my part working that out (looking at the code quickly cleared it up in that case).  For instance, the usage notes list:

  • DoRestart: restart the console

I took that to mean "DoRestart" was the message/command that needed to be sent, but the actual command that needs to be sent is "restart".  DoRestart appears to be be what the function is in the code. Might help the next guy to make that clearer.

FYI - I've been trying to figure out a way to clear the error notification via mqtt.  I often look at the logs via ssh'ing into the RPi and would like to be able to clear the error from issuing an mqtt command after looking at them.  Is that obvious too??  ?

Link to comment

You can clear the error notification.  The way that works is that each console records when its log starts (basically its startup time).  When you view a log on any console it broadcasts an update to a variable called GlobalLogViewTime that is its log start time.  Then any console with a first unseen error with a time later than that clears its flag.  This is done so that if a console starts after another one has seen an error, viewing the "newer" console log doesn't clear the error that occurred before it started.  Sort of a same if inexact way to not miss something.  So, if you want to get all the consoles to clear you'd publish to all a set of System:GlobalLogViewTime to 0 or some other small value.  You can see the code that does this in logsupport.py line 296.


 

 

 
Link to comment

Do you mean for my softconsole or did you post this in the wrong thread?  For softconsole pretty much everything is customizable but I'm confused by your reference to "standard Insteon buttons" since the console doesn't have anything referred to that way.  If you mean virtual buttons on the softconsole that correspond to Insteon devices then the softconsole documentation describes pretty well how to set their color and even change their color based on state of the device.

 

Link to comment

Sorry - I missed that you asked that before as I was leaving for a trip.  

There isn't at the moment but let me take a look at how hard it would be to add for you.  

 

Link to comment
21 hours ago, chrisb5 said:

Any way to get the page (room) name/title to show on the console so we can tell which room we're looking at?

Thanks!

Sent from my SM-G935V using Tapatalk
 

Kevin - I did this when I first implemented the console a while back - I wanted the same thing, and was able to split the two buttons at the bottom into three, so the middle one would show the current room, and then left and right were next and previous...  Of course, I lost it when I upgraded (which I expected) and hadn't gotten around to re-document it.  I have some loose notes that I took while doing it; which I can post here.  Disclaimer: I do not write code, so I was basically just hacking this as an experiment to see if I could do it.  My notes are not pretty, but might give you an idea.  Also, it appears I may have gotten distracted and not fully documented the changes to adjust the button width.

entries added to ~/consolestable/configobjects.py
 
                for i, kn in enumerate(config.MainChain):
                        prevk = config.MainDict[config.MainChain[i - 1]].screen
                        nextk = config.MainDict[config.MainChain[(i + 1)%len(config.MainChain)]].screen
# added by pfl; add third button to describe current screen.
                        thisk = config.MainDict[config.MainChain[(i)%len(config.MainChain)]].screen
 
                        config.MainDict[kn].prevkey = toucharea.ManualKeyDesc(config.MainDict[kn].screen, prevk.name, prevk.label,
                                                                                                                                  config.CmdKeyCol, config.CmdCharCol,
                                                                                                                                  config.CmdCharCol,
                                                                                                                                  proc=functools.partial(config.DS.NavPress, prevk),
                                                                                                                                  center=(
                                                                                                                                  config.horizborder + .5*cbutwidth, cvertcenter),
                                                                                                                                  size=(cbutwidth, cbutheight))
                        config.MainDict[kn].nextkey = toucharea.ManualKeyDesc(config.MainDict[kn].screen, nextk.name, nextk.label,
                                                                                                                                  config.CmdKeyCol, config.CmdCharCol,
                                                                                                                                  config.CmdCharCol,
                                                                                                                                  proc=functools.partial(config.DS.NavPress, nextk),
                                                                                                                                  center=(
                                                                                                                                          config.horizborder + 2.5*cbutwidth, cver$
                                                                                                                                  size=(cbutwidth, cbutheight))
# added by pfl; add third button to describe current screen.
 
                        config.MainDict[kn].thiskey = toucharea.ManualKeyDesc(config.MainDict[kn].screen, thisk.name, thisk.label,
                                                                                                                                  config.CmdKeyCol, config.CmdCharCol,
                                                                                                                                  config.CmdCharCol,
                                                                                                                                  proc=functools.partial(config.DS.NavPress, thisk),
                                                                                                                                  center=(
                                                                                                                                  config.horizborder + 1.5*cbutwidth, cvertcenter),
                                                                                                                                  size=(cbutwidth, cbutheight))
 
entries adjusting in ~/consolestable/displayscreen.py
 
# pfl; redefined trying to add third button - three lines commented and replaced
#               if NavKeys:
#                       nav = OrderedDict(
#                               {'prevkey': self.ScreensDict[self.AS.name].prevkey, 'nextkey': self.ScreensDict[self.AS.name].nextkey})
                if NavKeys:
                        nav = OrderedDict(
                                {'prevkey': self.ScreensDict[self.AS.name].prekey, 'thiskey': self.ScreensDict[self.AS.name].thiskey, 'nextkey':self.ScreensDict[self.AS.name].nextkey}) #end of change
 
made changes to configobjects for secondary chain and attempted to change width.

 

Link to comment

Wow - you really dug into that!  What I'm going to do is just add a general property on any screen for a title.  Some screens already have it as a specific feature (thermostat, weather) so I just need to rationalize those with the general capability.  I have a first test version running but want to make sure I haven't broken something.  I'll try to push a version to try next week - sooner if I get the time.

Link to comment

Just pushed a beta version with the screen title capability in it.  I've tested it but since I don't have a lot of use for this at this point I figured I'd turn it loose on you to try.  The title capability is enabled for most screen types: clockscreen, keyscreen, thermostatscreen(ISY and Nest), timetemscreen, weatherscreen.  There are 3 relevant keywords: ScreenTitle = string is the title (duh!), ScreenTitleColor = white is the text color, and ScreenTitleSize = 50 is the text size to use (obviously choose your color and size).  If you set a non empty title the rest of the screen shrinks vertically to allow the space.  Some of these screen types already had a label keyword.  That is still there, and if you don't set a ScreenTitle explicitly that value is used.  It is also used in any case for the nav key on the previous and next screens.  So this allows the nav name to be different that the title if you set them differently.  See if this gets you what you'd like or whether some other tweak would help.  I'll be traveling Wed through next Tuesday but may get on line to answer questions but can't update code until I'm back.  Enjoy!

(In case you haven't done it, get the beta by going to maintenance, selecting to use beta, download the beta from the same screen, and then restart the console.)

 

Link to comment
  • 1 month later...

Well, I decided to jump into the fray and sadly, after four attempts at starting with a fresh Raspbian Stretch install and running the pisetup.sh script, I'm just greeted with the tiny desktop after all the scripts finish and reboot.  I have a Pi 3B+ with the PiTFT Plus 3.5" from Adafruit.

Any idea how to troubleshoot this?

Thanks for the help...

Link to comment

Did you ask the scripts to have the console start automatically?  Sounds like after the install you are just rebooting to the standard Linux desktop.  Assuming you can access the system either on that tiny desktop or (preferably) via vnc from a real desktop, su to root and try systemctl status softconsole.  I would bet you will see that it isn't running or even possibly enabled.  Assuming that to be true, systemctl enable softconsole followed by systemctl start softconsole should start the console.  If this is not the issue then we can try to figure out what is really the problem, but the install scripts seem to be pretty reliable these days.  You might also look in the ~pi/Console directory to see if there is a Console.log file there and if so tell me what it in it.  The presence of such a file would indicate that the console did try to start but failed and then I'd expect something useful in the log.  Let me know in any case and I'll try to help you sort it out.

Kevin

Link to comment

Thanks for the help (and as much as I want this to work, I wish it was as simple as not letting it reboot.)  I have to SSH into the Pi because it's difficult to work with the desktop oriented in portrait mode.

Here's the output from systemctl:"

softconsole.service - SoftConsole
   Loaded: loaded (/usr/lib/systemd/system/softconsole.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Sat 2019-04-20 09:35:05 CDT; 1s ago
  Process: 1322 ExecStart=/home/pi/consolestable/runconsole.py (code=exited, status=0/SUCCESS)
  Process: 1319 ExecStartPre=/bin/sleep 5 (code=exited, status=0/SUCCESS)
 Main PID: 1323 (code=exited, status=1/FAILURE)

Apr 20 09:35:05 BODY-WARS systemd[1]: softconsole.service: Main process exited, code=exited, status=1/FAILURE
Apr 20 09:35:05 BODY-WARS systemd[1]: softconsole.service: Unit entered failed state.
Apr 20 09:35:05 BODY-WARS systemd[1]: softconsole.service: Failed with result 'exit-code'."

 

I think my instance is crashing before it creates the log, because I don't have a Console.log in the directory you mentioned. I tried to run it manually and I get this:

Traceback (most recent call last):
  File "console.py", line 44, in <module>
    import hasshub
  File "/home/pi/consolestable/hasshub.py", line 3, in <module>
    import haremote as ha
  File "/home/pi/consolestable/haremote.py", line 18, in <module>
    from aiohttp.hdrs import METH_GET, METH_POST, CONTENT_TYPE
ImportError: No module named 'aiohttp'

 

Funny thing is, in the last installation attempt, I saw that library being installed.  It's odd...

Again, thanks for your help!  I'm dying to get this going.

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...