[chbot] [OT] flick electric price logging

Simeon Pilgrim simeon.pilgrim at gmail.com
Wed Aug 29 22:31:35 BST 2018


I was using this python code:
https://github.com/driannaude/PyFlick

I was using this code plus pywinauto to turn things on/off




On 30 August 2018 at 08:50, Jasper Mackenzie <jasper.mackenzie at gmail.com>
wrote:

> They have an API they are not talking about and you have to be _on the
> list_
>  I am _on the list_ so hmm... we never used it in the end... WIll see if I
> can drag the details out.
> Maybe its not a good idea to flood them with requests for access just
> yet...
>
> On Thu, 30 Aug 2018 at 08:49, Spencer Travers <spencer.travers at gmail.com>
> wrote:
>
>> I have a project where I scrape the price from the Flick website every
>> five minutes (login required). This is done on a Raspberry Pi that then
>> displays the price and the trend on a strip of RGB LEDs in the kitchen. The
>> scraping has been pretty reliable but I would prefer to use the API if
>> anyone has the details.
>>
>> Spencer
>>
>> On Thu, Aug 30, 2018 at 8:32 AM Volker Kuhlmann <list57 at top.geek.nz>
>> wrote:
>>
>>> On Thu 30 Aug 2018 02:45:13 NZST +1200, Peter Ellens wrote:
>>>
>>> > Anyone interested? It is really simple to setup.
>>>
>>> I'd be extremely interested in running a logging script for this kind of
>>> purpose, but don't have a flick account...
>>>
>>> Volker
>>>
>>> --
>>> Volker Kuhlmann
>>> http://volker.top.geek.nz/      Please do not CC list postings to me.
>>>
>>> _______________________________________________
>>> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
>>> https://lists.ourshack.com/mailman/listinfo/chchrobotics
>>> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
>>> Meetings usually 3rd Monday each month. See http://kiwibots.org for
>>> venue, directions and dates.
>>> When replying, please edit your Subject line to reflect new subjects.
>>
>> _______________________________________________
>> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
>> https://lists.ourshack.com/mailman/listinfo/chchrobotics
>> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
>> Meetings usually 3rd Monday each month. See http://kiwibots.org for
>> venue, directions and dates.
>> When replying, please edit your Subject line to reflect new subjects.
>
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20180830/f8eeee14/attachment-0001.html>
-------------- next part --------------
"""
Main Module
"""
#!/usr/bin/env python
# encoding: utf-8

from classes.api.FlickApi import FlickApi
from classes.config.config import Config
from pywinauto import application
from pywinauto import mouse
import time


def main():
    """ Main, nuff said """
    config = Config().get()
    state = False
    price_level_cents = 30.0

    app=application.Application()
    app.Start('C:\\Users\\Simeon\\AppData\\Local\\Programs\\NiceHash Miner 2\\NiceHash Miner 2.exe')
    nhm2 = app.NiceHash
    nhm2.wait('visible')
    time.sleep(30) # wait another 30 seconds


    while True:
        # get price
        try: 
            api = FlickApi(config["username"], config["password"], config["client_id"], config["client_secret"])
        except:
            time.sleep(60)
            continue
        
        price_cents = float(api.getPricePerKwh())
        print('Price check', price_cents)
        
        can_run = price_cents <= price_level_cents 
        print('run check', can_run, state)
        
        if can_run != state:
            app.NiceHash.click(coords=(315,120))
            state = can_run
        next_time = api.getNextUpdateTime(True)
        sleep_time = min(round(next_time - time.time()),600)+20
        print('next', next_time, 'sleep', sleep_time)
        time.sleep(sleep_time)
    
if __name__ == "__main__":
    main()


More information about the Chchrobotics mailing list