Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - relay control based on selectable temperature sensor #721

Closed
Wholistic opened this issue Oct 29, 2020 · 10 comments
Closed
Assignees
Milestone

Comments

@Wholistic
Copy link

Much like how you can start a pump using the relay based on a tank level sensor reading,

Would be nice if you could open or close the relay based on a temperature reading.

For example, if temp gets >30 degrees, start the air conditioner or fans, until temp drops below 25 degrees.

Of course - this can already be done via Node Red (sort of).

@mpvader mpvader added this to the v2.70 milestone Nov 16, 2020
@nmbath
Copy link

nmbath commented Dec 21, 2020

Not sure if this is of any help, but here is a dbus service to control a relay based on temperature probes. Very similar to the Pump dbus service. I also copied the test harness from the pump service and it passes!

I also modified the velib_python file vedbus.py to use /Mgmt rather than /management

I have enumerated the relays so it can be applied to either relay 1 or 2.

If this can be used to speed up delivery a number of people in the community would be very pleased.

dbus-temperatureSwitch.tar.zip

@nmbath
Copy link

nmbath commented Jan 3, 2021

Further to my previous comment attached is a opkg package that will modify the system allowing temperature control of the relays. It also includes some changes to the dbus-digitalinputs to support input types from a BMS for Allow to Charge, Allow to Discharge and Pre Alarm.

The relay can be associated with any temperature source, either an analogue temperature input or a battery monitor providing /Dc/0/Temperature.

Once installed the files for the dbus-temperatureSwitch are located in /data/local/dbus-temperatureSwitch. This monitors a temperature sensor and triggers the relay, much in the same was as the dbus-pump. Diff files for the QML GUI files are in /data/local/MB-Modifcations as well as a diff for dbus-digitalinputs.

I have tested on a Cerbo and a Raspberry Pi. If this is of use please do use.

MB-Modifications_0.1_cortexa7hf-neon-vfpv4.ipk.zip

My test Raspberry Pi is available through VRM if you wish to log in and sniff around without actually installing the code yourselves.

@mpvader mpvader modified the milestones: v2.70, v2.80 Jun 28, 2021
@jepefe
Copy link
Collaborator

jepefe commented Dec 10, 2021

This feature has been implemented and added to the ToDo for including it in Venus.

The implementation supports two conditions per temperature sensor where each one consist on a temperature range (high or low) where the configured relay must be closed.

For example a temperature sensor in the battery cabinet can be used to switch on a fan in case of high temperature or a resistor to keep a Lithium battery above the cut-off temperature:

Condition 1
Activation temperature: 35ºC
Deactivation temperature: 25ºC
Relay: 1

Condition 2
Activation temperature: 4ºC
Deactivation temperature: 10ºC
Relay: 2

Both conditions can be set to activate the same relay. This might be useful to switch on an air conditioner (set to auto) in case of high or low temperatures.

Multiple sensors can control the same relay. Relay will keep closed as long as there are one active condition of any sensor.

Conditions can be configured in two places.

  1. From the temperature sensor menu: Devices list -> Temp sensor -> Setup -> Relay

Screenshot 2021-12-10 at 14 46 55

Screenshot 2021-12-10 at 14 47 02

  1. From the relay settings page(Settings -> Relay -> Temperature sensors), here a the sensors are listed showing the condition values to check them all in a glance. This menu is only shown if at least one of the relays is configured as a temperature relay.

Screenshot 2021-12-10 at 15 27 09

Screenshot 2021-12-10 at 15 32 59

Screenshot 2021-12-10 at 14 56 38

Screenshot 2021-12-10 at 14 56 25

@mpvader
Copy link
Contributor

mpvader commented Dec 10, 2021

Great!

@lennycb
Copy link

lennycb commented Dec 30, 2021

@jepefe What has to be done to use this with the internal CPU temp sensor from the Pi4 or a DS18B20 1-wire sensor.
According to the description, entries for the sensors and their values should be in the "Temperature sensors" tile. But is missing with me. What did i forget?
Geräteliste
Relais
Setup
Temp_Sensors

@kwindrem
Copy link
Collaborator

kwindrem commented Dec 30, 2021

This should be better discussed in the community forum.

I recall seeing a mod to make the RPI temp sensor visible. I tried it and worked fine but has not been upgraded for V2.80 (Python 3).

https://github.com/LHardwick-git/Victron-Service

@lennycb
Copy link

lennycb commented Dec 30, 2021

Hi @kwindrem, I have no problem with the ad. I've already adjusted the mod. See forum:
https://community.victronenergy.com/questions/58792/raspberry-pi-3b-heat-temperature.html?childToView=113688#comment-113688

So, they are displayed as they should, but unfortunately I cannot control relays with the sensors. I'm not sure if this is only intended for the RuuviTags.

@kwindrem
Copy link
Collaborator

Made a couple of tweaks to LHardwick's code to:

  1. make it run on both python 2 and 3

  2. make the CPU temp alarm relays available

The second problem was that the dbus service name included a dash (-) which caused com.victronenergy.temprelay to crash. Changed the - to _ and the alarm settings show up in the CPU temp sensor Setup menu.
dbus-i2c.py.zip

@lennycb
Copy link

lennycb commented Jan 1, 2022

Great, works. I hadn't thought of a change for Python2 and Python3. Will become obsolete after an update to Venus> v2.80.

What error are you seeing here?

# --------------------- was causing an error
#from w1thermsensor import W1ThermSensor
# ---------------------

I had to activate it again to read my DS18B20.

This library is normally not included and must be installed later.
To do this, I first had to install PIP, then the library.

@kwindrem
Copy link
Collaborator

kwindrem commented Jan 1, 2022

The error was that the import file could not be found but that makes sense based on your explanation.

I wrapped a try: except: pass around the import statement so it no longer fails:

dbus-i2c.py.zip

Here's my setup script that uses SetupHelper if you are interested:

RpiTemp.zip

You should be able to add the missing bits for the w1... stuff

To make this work with auto download and install, it needs to be available on GitHub. I generally set up a 'latest' tag for the most recent released version but that's optional. The branch/tag in PackageManager can simply be set to 'main'. You may wish to change the package name back to what you are using now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants