Coder Social home page Coder Social logo

mudpi / mudpi-core Goto Github PK

View Code? Open in Web Editor NEW
268.0 27.0 40.0 15.81 MB

Configurable automation library for linux SBC boards including raspberry pi

Home Page: https://mudpi.app

Python 99.02% JavaScript 0.98%
raspberry-pi python redis arduino garden automation

mudpi-core's Introduction

MudPi Smart Automation for the Garden & Home

MudPi Smart Automation for the Garden & Home

A python package to gather sensor readings, trigger components, control devices and more in an event based system that can be run on a linux SBC, including Raspberry Pi.

Documentation

For full documentation visit mudpi.app

Installation

Install MudPi using the Installer that will guide you through the process. You can also view the manual install instructions

Guides

For examples and guides on how to setup and use MudPi check out the free guides available.

Funding

MudPi core is open source and has a bunch of free resources built around it. Being a solo developer it has become quite a lot to maintain the various areas of the project. It makes me happy seeing how MudPi has helped many people worldwide. I would like to continue working on MudPi and put even more time into the project to take on bigger ambitions. However it has come to a point that MudPi is taking more time to build with little to no income to help justify it. I really could use help from the community to continue building MudPi. If you like my work and MudPi please consider helping me fund the project and keep the lights on.

Contributing

Any contributions you can make will be greatly appreciated. If you are interested in contributing please get in touch with me and submit a pull request. There is much more I would like to add support for, however being a single developer limits my scope. Therefore mainly bugs will be accepted as issues.

Versioning

Breaking.Major.Minor

Authors

Community

MudPi Hardware

There are custom circuit boards designed around MudPi available.

License

This project is licensed under the BSD-4-Clause License - see the LICENSE.md file for details

MudPi Smart Garden

mudpi-core's People

Contributors

olixr avatar p33ry avatar ryleysill93 avatar sect0uch avatar yeyeto2788 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mudpi-core's Issues

support for I2C relays

I have a GeeekPi relay expansion board mounted on my Raspberry Pi. It communicates over I2C and, although I can toggle each relay from the command line, it looks like there's only support for GPIO-controlled relays at the moment. I'd be happy to contribute an extension for this but I'm still getting familiarized with the MudPi platform. Can you give me a basic idea of the scope of such a feature? I get the sense that you're doing some non-trivial refactoring with this project and I'd want to stay consistent with that.

RPI 4 error - ImportError: cannot import name 'Beaglebone_Black_Driver' from 'Adafruit_DHT'

The following error message occurs after clean install on RPI when using this configuration.

Config

{
    "name": "MudPi",
    "debug": false,
    "logging": {
        "file_log_level": "debug",
        "terminal_log_level": "debug",
        "file": "mudpi.log"
    },
    "workers":[{
        "type":"sensor",
        "sensors": [
            {
                "type":"Humidity",
                "pin": 24,
                "key":"weather_sensor"
            }
        ]
    }]
}

Error

File "/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/Beaglebone_Black.py", line 24, in <module>
    from . import Beaglebone_Black_Driver as driver
ImportError: cannot import name 'Beaglebone_Black_Driver' from 'Adafruit_DHT' (/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/init.py)

Based on the research this is a common problem with the old Adafruit_DHT on RPI4. the suggested workaround here resolved my issue.

https://stackoverflow.com/questions/63232072/cannot-import-name-beaglebone-black-driver-from-adafruit-dht

Configuring remote redis in mudpi.config broken

Description

When trying to configure a remote redis to be used by mudpi-core inside the mudpi.config, the settings are ignored and it tries to default to a local connection.

Reproduction

  1. Setup mudpi-core on host1
  2. Setup a redis server on host2
  3. Configure mudpi-core to use the redis server on host2
  4. Start mudpi-core and see it trying to connect to a local redis on host1

Current Workaround

Editing the hard-coded connection details in variables.py lets you define the connection details

Arduinio is not reconized

I followed the Arduino guide and Mudpi seems to have an issue connecting to the slave Arduino UNO i have. Right now i have nanpi firmware on my UNO and installed nanpi to the pi according to the link below. After doing this I notice a /dev/ttyACM0 comes and go when the Uno USB port is plugged/unplugged into the PI USB port. I assume ACMO is the right port and entered that into the mudpi config file that was generated by mudpi.app website. Not sure what I'm doing wrong. Maybe a bug?

https://mudpi.app/guides/9
https://nanpy.github.io/

Boot screen of Mudpi shows successful serial for my UNO and right under it complains about the Node connection.
__ __ _ _____ _ | \/ | | | __ (_) | \ / |_ _ __| | |__) | | |\/| | | | |/ _ | / |
| | | | |
| | (
| | | | |
|
| ||_,|_,|| |_|


Eric Davisson @theDavisson
Version: 0.8

Initializing Garden Control... Complete
Preparing Threads for Workers... Complete
No Camera Found to Load
Loading Pi Sensor Worker...
Pi Sensor Worker [2 Sensors]... Running
[Arduino] Serial Connection Success
Invalid or no Nodes found to Load
No Actions Found to Load
No Triggers Found to Load
MudPi Server... Running
MudPi Garden Control... Online


`

Install script unable to create redis.ini file in php/mods-available

Fresh Bullseye Rapsberry pi image on Rapsberry Pi 4. Installation stops with:

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: RPi.GPIO in /usr/lib/python3/dist-packages (0.7.0)
rm: cannot remove 'composer-setup.php': No such file or directory
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
redis-server is already the newest version (5:6.0.16-1+deb11u2).
The following package was automatically installed and is no longer required:
libfuse2
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
sudo: pecl: command not found
touch: cannot touch '/etc/php//mods-available/redis.ini': No such file or directory
MudPi Install Error: Unable to create redis.ini file in php/mods-available

I have verified that /etc/php/8.1/mods-available does exist.

Even if I touch the requested file, the install cannot continue. It seems that it cannot find the directory.

Loading DHT and another component causes DHT to not read on ARMv6

When using both a DHT sensor and any other component it causes the DHT sensor to always error with "Not a full buffer returned" The same config works on the RPi4 (ARMv7) but has issues on the RPi zero (ARMv6)

Doing some digging it is unclear what the issue is. My assumption is that there is some sort of resource being used by both libraries and its interfering with the other. Loading just a DHT sensor alone gets consistent readings. Adding another component like an example sensor then DHT now fails to read.

Even more interesting is creating a simple test script it appears that threading is not an issue and this works:

import time
import board
from busio import I2C
import adafruit_bme680
import adafruit_dht
import threading

def read_bme():
    # Create library object using our Bus I2C port
    i2c = I2C(board.SCL, board.SDA)
    bme680 = adafruit_bme680.Adafruit_BME680_I2C(i2c, debug=False)

    # change this to match the location's pressure (hPa) at sea level
    bme680.sea_level_pressure = 1013.25

    temperature_offset = -5

    while True:
        print("\nTemperature: %0.1f C" % (bme680.temperature + temperature_offset))
        print("Gas: %d ohm" % bme680.gas)
        print("Humidity: %0.1f %%" % bme680.relative_humidity)
        print("Pressure: %0.3f hPa" % bme680.pressure)
        print("Altitude = %0.2f meters" % bme680.altitude)

        time.sleep(5)

def read_dht():
    # Initial the dht device, with data pin connected to:
    dhtDevice = adafruit_dht.DHT22(board.D24)

    while True:
        try:
            # Print the values to the serial port
            temperature_c = dhtDevice.temperature
            temperature_f = temperature_c * (9 / 5) + 32
            humidity = dhtDevice.humidity
            print(
                "Temp: {:.1f} F / {:.1f} C    Humidity: {}% ".format(
                    temperature_f, temperature_c, humidity
                )
            )

        except RuntimeError as error:
            # Errors happen fairly often, DHT's are hard to read, just keep going
            print(error.args[0])
            continue
        except Exception as error:
            dhtDevice.exit()
            raise error
        time.sleep(2)

dht_thread = threading.Thread(target=read_dht)
bme_thread = threading.Thread(target=read_bme)

dht_thread.start()
bme_thread.start()
time.sleep(30)
print("DONE")

Yet when the same code is applied to the MudPi system it has errors.

Tested on Pi Zero W using MudPi v0.10.0

Any help debugging and investigating this would be very helpful.

You will be looking in the mudpi/extensions/dht/sensor.py file.

Test Cases

Should add unit testing and other test cases to make code more maintainable.

install on fresh pi results in error unable to install pip3 packages

Describe the bug
using a brand new Raspberry Pi 4 and flashed SD card I tried installing mudpi and as it's almost done it gets the error: unable to install pip3 packages. I have tried using commands curl -sL https://install.mudpi.app | bash and curl -sL https://install.mudpi.app | bash -s -- -b feature and no avail

Paste the error message here:
Unable to install pip3 packages

To Reproduce
Steps to reproduce the behavior:
type curl -sL https://install.mudpi.app | bash into terminal and wait

Expected behavior
should install Mudpi no probelm

Hardware (please complete the following information):

  • OS: [e.g. Raspberry OS newest 64bit]
  • Board [e.g. raspberry pi 4,]
  • MudPi Version [e.g. v0.10.0]

Proper way to add a feature

I would like to calculate Vapour Pressure Deficit on each climate sensor reading (if enabled via config). It requires the temperature and the relative humidity in the air.

Then I would like to be able to use a state trigger with a threshold on the result.

This feature should be sensor independent and shouldn't be present in dht or t9602 extensions.

I'm not sure on where to start to implement that. Should I create an extension ?

Help with adding support for I2C Capacitive Moisture Sensor from adafruit

Great project, hoping to get mudpi working with my I2C Capacitive Moisture Sensor which uses i2c.

I've got it running successfully in Python on the rpi and am looking for direction on how to integrate it with mudpi.

It uses the ATSAMD10 chipset and default i2c address of 0x36.

Schematic is here:
image

Any thoughts on how to proceed?

Thanks!

Hamburger Menu not clickable on mobile

Hello,
First off, great work on this, it's awesome!
I too am a web developer, and I've thoroughly enjoyed getting to know both Raspberry Pi and MudPi. You did alot of great work under the hood. Very impressive.
I hope to be able to contribute to the project in the future.
Until then, just wanted to alert you to the an issue I noticed.
When I visit my localhost/ site MudPi sets up, on my iPhone 6s the hamburger menu doesn't open / not clickable.
I didn't look into it yet, but my guess would be it just needs a position and higher z-index set via CSS. It's like it's behind the main layer and thus unclickable.
Anyways, wanted to let you know and also say awesome job!

Fails to run on Rasp Pi A

I've been trying to set MudPi up on an old Raspberry Pi A.

I've managed to get the installer to complete without any errors. It's running buster fine. I get the setup when I log in via the web browser setup but I soon as I click "Get Started" I get a "500 internal server error"

If I try to run MudPi Manually from the CLI I get the following error:

Traceback (most recent call last):
File "mudpi.py", line 27, in
from workers.adc_worker import ADCMCP3008Worker
File "/etc/mudpi/core/workers/adc_worker.py", line 14, in
class ADCMCP3008Worker:
File "/etc/mudpi/core/workers/adc_worker.py", line 23, in ADCMCP3008Worker
'5': board.D5,
AttributeError: module 'board' has no attribute 'D5'

I've been googling all afternoon but can't seem to narrow down the problem?

Install on fresh PI fails

Describe the bug

Can't install mudpi due to the following error:

Root composer.json requires php ^7.2 but your php version (8.2.8) does not satisfy that requirement.

List any error messages / strack trace

Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires php ^7.2 but your php version (8.2.8) does not satisfy that requirement.

MudPi Install Error: Unable to run composer install

To Reproduce
Steps to reproduce the behavior:

1. Run the main installer and select Y for all except AP

Expected behavior

It installs successfully 

Debug Logs

I can't run Mudpi in debug mode as it can't install

Paste output log here


Paste error logs here


**Screenshots**

If applicable, add screenshots to help explain your problem.


**Hardware (please complete the following information):**
  • OS: Debian GNU/Linux 11 (bullseye)
  • Board: Raspberry pi 4
  • MudPi: 0.10.0

Support for other boards

Would you consider support for other boards ?

I have a setup with a Pine64, started developping something similar and came across your project (which is awesome btw).

One blocking problem is the dependency RPi.GPIO, which works with Raspberry Pi only.
One possible solution would be to migrate to python-periphery.

I'm willing to contribute to the project in a separate branch to go in that direction if you're OK with that.

Threading locks up during KeyboardInterrupt shutdown

Issue


MudPi gets stuck during shutdown due to threading issue. To fully exit mudpi.py, you must KeyboardInterrupt 2 more times. This seems to have started after integrating more sensors and nodes (aka it used to successfully shut down with less integrated pieces)

MudPi Version


v0.8.10

MudPi Config


Initializing Garden Control... Complete
Preparing Threads for Workers... Complete
No Camera Found to Load
Humidity Sensor (Pi) 18... Ready
Loading Pi Sensor Worker...
Pi Sensor Worker [4 Sensors]... Running
Float Sensor (Pi) 17... Ready
Float Sensor (Pi) 27... Ready
Loading Pi Sensor Worker...
Pi Sensor Worker [4 Sensors]... Running
Relay Worker pump1... Ready
Relay Worker pump1... Running
Relay Worker water_ch1... Ready
Relay Worker water_ch1... Running
Relay Worker water_ch2... Ready
Relay Worker water_ch2... Running
Relay Worker water_ch3... Ready
Relay Worker water_ch3... Running
Relay Worker water_ch4... Ready
Relay Worker water_ch4... Running
Relay Worker water_ch5... Ready
Relay Worker water_ch5... Running
Relay Worker water_ch6... Ready
Relay Worker water_ch6... Running
Relay Worker water_ch7... Ready
Relay Worker water_ch7... Running
Relay Worker water_ch8... Ready
Relay Worker water_ch8... Running
slave2 -> Wifi Connection Success
Soil Sensor 5... Ready
slave2 Node Worker [S: 1][C: 0]... Running
Loading Triggers...
Trigger Worker [1 Triggers]... Running
MudPi Server... Running
MudPi Garden Control... Online

Python Errors


Switch Relay pump1 state to 0
Pi Temp: {'temperature': 69.8, 'humidity': 41.0}
{'soil1': 1023}
{'soil1': 1023}
{'soil1': 1023}
{'soil1': 1023}
Switch Relay pump1 state to 0
^CMudPi Shutting Down... <---KeyboardInterrupt (CTRL + C) given
Server Shutdown... Complete
slave2 Controls Shutting Down... Complete
Relay Worker water_ch4 Shutting Down... Complete
Relay Worker water_ch5 Shutting Down... Complete
Relay Worker water_ch8 Shutting Down... Complete
Relay Worker water_ch1 Shutting Down... Complete
Relay Worker pump1 Shutting Down... Complete
Relay Worker water_ch6 Shutting Down... Complete
Relay Worker water_ch3 Shutting Down... Complete
Relay Worker water_ch2 Shutting Down... Complete
Relay Worker water_ch7 Shutting Down... Complete
slave2 Sensors Shutting Down... Complete
slave2 Shutting Down... Complete
Trigger Worker Shutting Down... Complete
Pi Sensor Worker Shutting Down... Complete <--- shutdown hangs
^CTraceback (most recent call last): <---Second KeyboardInterrupt
File "mudpi.py", line 259, in
thread.join()
File "/usr/lib/python3.7/threading.py", line 1032, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt
^CException ignored in: <module 'threading' from '/usr/lib/python3.7/threading.py'> <---3rd
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 1281, in _shutdown
t.join()
File "/usr/lib/python3.7/threading.py", line 1032, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt
Exception ignored in: <function Connection.del at 0x76534390>
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/redis/connection.py", line 537, in del
File "/home/pi/.local/lib/python3.7/site-packages/redis/connection.py", line 667, in disconnect
TypeError: catching classes that do not inherit from BaseException is not allowed

Option to run only one relay at time of queue relay operations and voltage sensor integration to run relays only if main power supply to run water pump is available

For systems run on main power supply(irrigular) to run pumps from borewell or well there could be interruption due to power loss of pump(with raspberry pi running on battery all the time). In such situation system should check if main power supply is available to run the relays. Also in case interruption, at the end of whole schedule, system should check if all relays were run for scheduled time/duration and if not then start auto watering for remaining duration. E.g if schedule was to run relay1for 10min and due to interuption it ran for only 5 min then at the end of schedule of all relays, there should be automated watering for 5 min for ralay1.
Also option to queue in additional triggered relay activations could be awesome feature. Thank u.

0.10.0 installer on Pi 3B running raspbian 10 wont work

Installer on Pi 3B running raspbian 10 wont be able to install.

Shows:

Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 143, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 338, in run
resolver.resolve(requirement_set)
File "/usr/lib/python3/dist-packages/pip/_internal/resolve.py", line 102, in resolve
self._resolve_one(requirement_set, req)
File "/usr/lib/python3/dist-packages/pip/_internal/resolve.py", line 261, in _resolve_one
check_dist_requires_python(dist)
File "/usr/lib/python3/dist-packages/pip/_internal/utils/packaging.py", line 55, in check_dist_requires_python
if not check_requires_python(requires_python):
File "/usr/lib/python3/dist-packages/pip/_internal/utils/packaging.py", line 33, in check_requires_python
return python_version in requires_python_specifier
File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/specifiers.py", line 676, in contains
return self.contains(item)
File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/specifiers.py", line 681, in contains
item = parse(item)
File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/version.py", line 28, in parse
return Version(version)
File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/version.py", line 219, in init
match = self._regex.search(version)
TypeError: expected string or bytes-like object
MudPi Install Error: Problem installing MudPi core python package




Build Error

I been following the step by step guide found here https://mudpi.app/guides/8 . When I run the mudpi.py i receive the following output. Is the Server error normal? I rebuilt the PI twice now with the same result.

`Initializing Garden Control... Complete
Preparing Threads for Workers... Complete
No Camera Found to Load
Humidity Sensor (Pi) 25... Ready
Loading Pi Sensor Worker...
Pi Sensor Worker [2 Sensors]... Running
No Relays Found to Load
Traceback (most recent call last):
File "mudpi.py", line 144, in
for relay in CONFIGS['relays']:
KeyError: 'relays'
Invalid or no Nodes found to Load
Traceback (most recent call last):
File "mudpi.py", line 167, in
for node in CONFIGS['nodes']:
KeyError: 'nodes'
No Actions Found to Load
Traceback (most recent call last):
File "mudpi.py", line 191, in
for action in CONFIGS["actions"]:
KeyError: 'actions'
No Triggers Found to Load
Traceback (most recent call last):
File "mudpi.py", line 201, in
t = TriggerWorker(CONFIGS['triggers'], main_thread_running, system_ready, actions)
KeyError: 'triggers'
MudPi Shutting Down... Starting
Traceback (most recent call last):
File "mudpi.py", line 216, in
server = MudpiServer(main_thread_running, CONFIGS['server']['host'], CONFIGS['server']['port'])
KeyError: 'server'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "mudpi.py", line 247, in
server.sock.shutdown(socket.SHUT_RDWR)
NameError: name 'server' is not defined
`

MudPi Install Error Message

Had a Raspberry Pi 3 collecting dust and figured I'd try to put MudPi on it. Loaded a new SD card with a fresh install of Raspberry Pi OS. The only thing I've changed on the fresh install is the password and haven't started to lock down the Raspberry Pi yet. I followed the install guide and executed the curl command to run the bash script and ran into an issue where it can't seem to install some core python packages - see screenshot below that I have in my Google Drive:

Error Message

Not sure if this is a factor, but since the Raspberry Pi I have is the old 3 model (not the 3b+), it is running on a 32-bit OS. I ran the command "uname -m" and got the output of "armv71", which by the power of Google, tells me that it's a 32-bit processor. Don't know if it'll matter much, but I figured I'd mention it.

If there's a log that I can provide, let me know; tried looking at syslogs, but I didn't find anything useful there.

How to use sensor trigger

Hi @olixr

I'm having trouble making the sensor trigger working.

Given the following config:

{
    "name": "NewBoard SecT0uch",
    "version": 0.8,
    "debug": true,
    "redis": {
        "host": "127.0.0.1",
        "port": 6379
    },
    "relays": [
        {
            "pin": "D17",
            "normally_open": true,
            "name": "Light",
            "topic": "garden/linux/relays/1",
            "key": "relay_light"
        },
        {
            "pin": "D27",
            "normally_open": true,
            "name": "Humidifier",
            "topic": "garden/linux/relays/2",
            "key": "relay_humidifier"
        }
    ],
    "workers": [
        {
           "type": "i2c",
           "sensors": [
                {
                    "address": 40,
                    "type": "T9602",
                    "key": "mytemphumsensor",
                    "name": "mytemphumsensor"
                }
           ]
        }
    ],
    "triggers": [
        {
            "type": "sensor",
            "source": "mytemphumsensor",
            "nested_source": "humidity",
            "key": "humidity_low",
            "name": "Humidity is low",
            "actions": ["turn_on_humidifier"],
            "frequency":"once",
            "thresholds": [
                {
                    "comparison": "lt",
                    "value": 50
                }
            ]
        },
        {   
            "type": "sensor",
            "source": "mytemphumsensor",
            "nested_source": "humidity",
            "key": "humidity_high",
            "name": "Humidity is high",
            "actions": ["turn_off_humidifier"],
            "frequency":"once",
            "thresholds": [
                {   
                    "comparison": "gt",
                    "value": 55
                }
            ]
        }
    ],
    "actions": [
        {
            "type": "event",
            "name": "Turn on Humidifier",
            "key": "turn_on_humidifier",
            "action": {"event": "Toggle"},
            "topic": "garden/linux/relays/2"
        },
        {
            "type": "event",
            "name": "Turn off Humidifier",
            "key": "turn_off_humidifier",
            "action": {"event": "Toggle"},
            "topic": "garden/linux/relays/2"
        }
    ]
}

The temperature and humidity are red properly every 30 seconds, however the trigger is never triggered . It seems the function handle_event() in sensor_trigger.py is never called.

Is it a configuration mistake ?
Or maybe it's due to the I2C nature of my sensor ?

Also, I couldn't find in the doc or in the example how to declare a Switch action. It seems @P33ry had the same question, maybe you figured it out?

Is it like this ?:

 "actions": [
        {
            "type": "event",
            "name": "Turn on Humidifier",
            "key": "turn_on_humidifier",
            "action": {"event": "Switch", "data": 1},
            "topic": "garden/linux/relays/2"
        },
        {
            "type": "event",
            "name": "Turn off Humidifier",
            "key": "turn_off_humidifier",
            "action": {"event": "Switch", "data": 0},
            "topic": "garden/linux/relays/2"
        }
    ]

Thanks guys!

Improve time scheduling

Hey,

I'm thinking about a way to improve the Time Trigger scheduling.

My initial concern was to be able to detect if we missed a schedule and correct the relay position.
Exemple:

  • I have 2 daily triggers to switch the lights on and off, let's say: On at 8:00, Off at 21:00
  • If if I start mudpi for the first time at 10:00, I want my lights to be "On" because we are in schedule

I know this is possible use pycron's has_been() function.

Shouldn't we change the Time Trigger declaration or create a new trigger type daily_schedule?
It would take 2 options, let's say schedule_on and schedule_off.

In the init we would add something like:

from datetime import date
from datetime import datetime


today = date.today()
midnight = datetime.combine(today, datetime.min.time())

if pycron.has_been(schedule_on, midnight) and not pycron.has_been(schedule_off, midnight):   # if in schedule
   <Turn the relay On>

Do you have any better idea on how to implement this?

I can contribute to implement that if needed.

Initial configuration error

I have installed mudpi, mudpi assistant and UI , without error. I could connect to AP(192.168.2.1). But then after clicking 'getting started' next page is not loading. Also in terminal, running mudpi.py gives error as
mudpi.config file not found

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.