Dim a display with a raspberry - python

I'm using the Pi3 and the last jessie-lite OS, and I want to manage the brightness of the screen like Kodi does with the dim screensaver.
After some google searching I found some tips but nothing works.
I'll be using an external light sensor and I want to manage the brightness proportionally at the value sent by the light sensor.
For the moment, I develop in Python2.7 but the issue can use another language or by shell.
Thank you very much!

ideally what you want would have been for the Kodi json api to support setting the screensaver, from what I understand it doesn't.
that said if your familiar with Python, and I'm not, you can develop a plug in that opens a socket (or communicates otherwise) with your program running on your pi, because from what I understand plugins have the ability to set the screensaver.
in other words, make a plug in that sends and receives message to and from the pi.
this is not really an answer because im not familiar with creating Kodi plugins, but I know it's possible because there are other plugins that do it...

Related

How to use Python to make Minecraft Java Deep Learning bots

Okay I have an idea that make be theoretical. I was looking at this paper, and I saw that they used something called Malmo to interact with Minecraft. I took a quick look at this and I saw this was a offline thing. I want to make a program to directly interact with Minecraft Java. I thought about using some library to read pixel data and using the keyboard library for input. This would work of course but I want to also fetch things like player position, inventory, and other things. I would ideally want this to work client side. So my final question is how would I be able to test neural network Minecraft bots with python on pure Minecraft Java? Would I need to make a Forge or Fabric client?
I don't think this is possible in Python but maybe in JavaScript/ Node.js with a library called Mineflayer. you can't directly send keystrokes and mouse input from Python because Minecraft will receive it as a digital input and simply won't respond properly. here is the Mineflayer Github where you can find how to use it and various addons to MineFlayer such as MineFlayer-pathfinder or MineFlayer-navigate.

Google assistant to run python script

I have installed the google assistant SDK on a raspberry pi 3 and have so far managed to get Spotify working, and managed to get IFTTT to run for lights. What I really want to know is whether it is possible to have google assistant run and interact with python scripts on the pi. By which I mean I have a script called sound_the_alarm.py which pulls news from different sources, gives updates on bitcoin etc, and then plays a random song from my library, and turns on a light via gpio. I would like to be able to say “ok google sound the alarm at 7:00 tomorrow and have it update the crib tab with an instance of the alarm. Is this possible? I have found nothing online suggesting so!
Thanks
Will
It is possible, but not directly, as I know.
I use IFTTT for that (check on youtube how easy it is).
The easiest way is to have public IP with your raspberry, but it is dangerous (see below for solution).
Log into ifttt.com and make an applet: Google Assistant Command to Webhook. It is a piece of cake. You will learn it in minutes (use youtube for tutorial).
You type as a webhook public IP of your raspberry with a link to PHP app.
Your PHP app fetches the info about command from Google Assistant and exec("Your command here");
Additional info:
It is probably possible to make fetching app in Python instead of PHP, but I am not a Python programmer, so I cannot help with it. I use PHP for that.
It is MUUUCH SAFER to make additional "Gate Server". Take the cheapest hosting provider. Make an APP on this server (probably in PHP :P). Your IFTTT sends a request to the Gate (instead of raspberry directly). And your raspberry pi contacts the gate checking if there are no any orders for it. If there is any, it follows the order. Because of that nobody knows your raspberry IP address. You can hide it behind the router so it is more less safe.
I hope my solution is understandable :).
K.

Right tools to make a GUI / web interface app

What I want to create is a music player that can interact with YouTube using its Data API.
I actually have already developed my application (only for Windows, multi-platform is not a priority at the moment) using AutoIt and it's working properly. For now I createad a GUI to simply execute mpv.io, send commands to it and get its STDOUT to manage informations/errors.
Now I wanted to create a web interface to control this application using my smartphone in particular. I tried to look into TCP implementation and also WebSockets to send real time information like the playback position, but I'm not too sure what to look into.
As you probably can understand, I don't have much experience especially in network stuff so a help would be much appreciated. In the past I've fiddled with HTML,CSS,JavaScript so the web interface should not be a problem but for the communication part I don't have many ideas.
Since I created some very basic application with Python in the past, someone already suggested me to use a web framework like Flask, and so I started to properly learn Python but I find difficulties with GUIs...
So, to do a little summary I'm currently asking what can be a proper method to develop this application, also starting from scratch and changing programming language, since I'm always open to learn something new.

How do python scripts work?

I just learned how to read and send emails using python and I read that you can create a python script that can read someone's twitter or facebook and send you an email whenever a specific person posts something on twitter or facebook, but how does this work?
What is the difference between a script and just a regular program? I don't think that if someone is doing something like this that they would need to have their computer on at all times and have the python program running in the background, or is that what is happening?
A python script is a kind of program.
To make what you're talking about, you'd need to either have some kind of notification when someone tweets or something to check constantly for new content.
Either way, the computer will have to be on at all times (for that, you could use a Raspberry Pi for example, so you don't take that much power). (EDIT : you can of course also have a server doing that for you, but it's still a computer running at all times.)
You'll need to get your hand onto the Twitter API documentation. There is probably a python wrapper.
(EDIT:Tweepy - Would be the aforementioned python wrapper)

Access webcam over internet using Python

I have written a program using Python and OpenCV where I perform operations on a video stream in run time. It works fine. Now if I want to publish it on a website where someone can see this using their browser and webcam, how do I proceed?
not really sure what you want to happen but if your going to implement this kind of feature in a website I think you should use a flash application instead of python (or if possible html 5). though your using python on the development of you web app it would only run on the server side instead and the feature you want to use is on a client side so for me it's more feasible to use flash instead to capture the video then after capturing the video you upload it to your server then your python code will do the rest of the process on the server side.

Categories