Thanks, that's what we needed.

Schematically, this would look something like the following. I've left out
details, but if you've already done one service, you should be able to
follow it. If not, let me know. NOT TESTED!


class WaterConsumption(StdService):
    """Service that sends email if my water consumption is too high"""

    def __init__(self, engine, config_dict):
        # Pass the initialization information on to my superclass:
        super(WaterConsumption, self).__init__(engine, config_dict)

        # Get email info, as in the alarm.py example
        ...

        # Bind to the NEW_ARCHIVE_RECORD event
        self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)

    def new_archive_record(self, event):
        """Called when a new archive record has arrived."""

        db_lookup = self.engine.db_binder.bind_default()
        time_binder = weewx.tags.TimeBinder(db_lookup,
event.record['dateTime']

        todays_water = time_binder.day().water.sum
        if todays_water > 2000:
            # Send an email (as in the alarm.py example)
            ...





On Fri, Dec 21, 2018 at 1:15 AM Mic G77 <[email protected]> wrote:

> Thank you for your interest in my problem.
>
> I' m creating a new service.
> I've already created a data record 'water' which gives me my water
> consumption.
> It works on the basis of the electricity.py exemple.
> Now i want to create an email alarm when my total day consumption is above
> a certain amount. (Here, my service will be built on the alarm.py exemple).
>
> If I was using a Template, i would write $day.water.sum but as it is in a
> service, I don't have access to this kind of tag. (at least I don't know
> how to do it).
>
> So, the easiest way seems to me to have access the day table of the
> archive.
> I would like to do it properly (for exemple, i don't want to write
> '/var/lib/weews/archive' in an sql command).
> Thank you in advance.
>
>
>
>
> Le vendredi 21 décembre 2018 10:01:59 UTC+1, Andrew Milner a écrit :
>
>> As tom says - a little more information would be helpful.
>>
>> If you just want to retrieve data from the database then a python program
>> can of course access any table in the weewx database by using sql search
>> commands.  All depends what you are actually trying to do and what you want
>> to do with the data once it has been retrieved.
>>
>>
>>
>> On Friday, 21 December 2018 10:20:38 UTC+2, Mic G77 wrote:
>>>
>>> Hello.
>>> I just want to gain access to daily summaries.
>>>
>>>
>>> Le jeudi 20 décembre 2018 23:31:49 UTC+1, Thomas Keffer a écrit :
>>>
>>>> Hello,
>>>>
>>>> There are a lot of ways to do this, so it would help if we knew a
>>>> little more about what you want to do with the data. For example, are you
>>>> trying to calculate an aggregate? Or, just gain access to the daily
>>>> summaries?
>>>>
>>>> -tk
>>>>
>>>> On Thu, Dec 20, 2018 at 1:38 PM Mic G77 <[email protected]> wrote:
>>>>
>>>>> Hello,
>>>>> i'm trying to do a new service. I'm rather a beginner in python
>>>>> although i have already developped some services in the
>>>>> /usr/share/weewx/user/ folder;
>>>>> In one of them, i would like to have access to some date which are in
>>>>> the archive_day_outTemp.
>>>>>
>>>>> I don't know how to do. It seems that in the event that is send in the
>>>>> new_archive_record function, there is only the actual record stored in the
>>>>> database.
>>>>> If someone could send a simple exemple, it would help me.
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "weewx-user" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to