ReefRhythm - Advance Stepper Motor Controller with OpenSource

butch708

New Member
View Badges
Joined
May 15, 2024
Messages
17
Reaction score
4
Location
Germany
Rating - 0%
0   0   0
I'm too stupid to set up mqtt. Maybe it would be a good idea to test the connection to mqtt server in the webgui.?

home-assistant.log
Code:
2024-05-30 19:03:49.658 ERROR (MainThread) [homeassistant.components.automation.start_dosing_pump] Start Dosing Pump: Error executing script. Error for call_service at point of sale 1: Error rendering data template: ValueError: Template error: float got invalid input 'unknown' when rendering template '{
  "id": 1,
  "direction": {% if is_state('input_boolean.dosing_pump_direction', 'on') %}1{% else %}0{% endif %},
  "amount": {{ states('input_number.dosing_pump_amount') | float }},
  "duration": {{ states('input_number.dosing_pump_duration') | float }}
}' but no default was specified
2024-05-30 19:03:49.658 ERROR (MainThread) [homeassistant.components.automation.start_dosing_pump] Error while executing automation automation.start_dosing_pump: Error rendering data template: ValueError: Template error: float got invalid input 'unknown' when rendering template '{
  "id": 1,
  "direction": {% if is_state('input_boolean.dosing_pump_direction', 'on') %}1{% else %}0{% endif %},
  "amount": {{ states('input_number.dosing_pump_amount') | float }},
  "duration": {{ states('input_number.dosing_pump_duration') | float }}
}' but no default was specified
2024-05-30 19:03:51.190 ERROR (MainThread) [homeassistant.components.automation.start_dosing_pump] Start Dosing Pump: Error executing script. Error for call_service at point of sale 1: Error rendering data template: ValueError: Template error: float got invalid input 'unknown' when rendering template '{
  "id": 1,
  "direction": {% if is_state('input_boolean.dosing_pump_direction', 'on') %}1{% else %}0{% endif %},
  "amount": {{ states('input_number.dosing_pump_amount') | float }},
  "duration": {{ states('input_number.dosing_pump_duration') | float }}
}' but no default was specified
2024-05-30 19:03:51.191 ERROR (MainThread) [homeassistant.components.automation.start_dosing_pump] Error while executing automation automation.start_dosing_pump: Error rendering data template: ValueError: Template error: float got invalid input 'unknown' when rendering template '{
  "id": 1,
  "direction": {% if is_state('input_boolean.dosing_pump_direction', 'on') %}1{% else %}0{% endif %},
  "amount": {{ states('input_number.dosing_pump_amount') | float }},
  "duration": {{ states('input_number.dosing_pump_duration') | float }}
}' but no default was specified

automations.yaml

Code:
- id: Start Dosing Pump
  alias: "Start Dosing Pump"
  trigger:
    - platform: event
      event_type: state_changed
      event_data:
        entity_id: input_button.start_dosing_pump
  action:
    - service: mqtt.publish
      data_template:
        topic: "/ReefRhythm/24587cda78dc/dose"
        payload: >
          {
            "id": 1,
            "direction": {% if is_state('input_boolean.dosing_pump_direction', 'on') %}1{% else %}0{% endif %},
            "amount": {{ states('input_number.dosing_pump_amount') | float }},
            "duration": {{ states('input_number.dosing_pump_duration') | float }}
          }
  mode: single

- id: Stop Dosing Pump
  alias: "Stop Dosing Pump"
  trigger:
    - platform: event
      event_type: state_changed
      event_data:
        entity_id: input_button.stop_dosing_pump
  action:
    - service: mqtt.publish
      data_template:
        topic: "/ReefRhythm/24587cda78dc/stop"
        payload: >
          {"id": 1}
  mode: single

If I start one of the pumps in the reefrhythm webgui, it should be displayed in mqtt explorer, right? Unfortunately it won't for me.

I somehow have the feeling that the reff rhythm can't connect with the mqtt brocker. I'm probably making a mistake somewhere.
i have it.



Screenshot 2024-05-30 221853.png


mqtt broker: homeassistant

im stupid, was testing broker adresses: core-mosquitto, core-mosquitto.hass.io and so on. Simply homeassistant :) :)
 

butch708

New Member
View Badges
Joined
May 15, 2024
Messages
17
Reaction score
4
Location
Germany
Rating - 0%
0   0   0
Hello yury,

https://github.com/telenkov88/reefr...me-Assistant-Dosing-Pump-Control-Setup-Manual

Code:
Number for Amount
Navigate to Settings > Devices & Services > Helpers.
Click + Create Helper.
Select Number.
Name it Dosing Pump Remains
Select icon mdi:cup-water
Select display mode input field
Specify a range (e.g., minimum 0, maximum 1000).
Set the unit of measurement to mL.

Code:
- alias: "Start Dosing Pump"
  trigger:
    - platform: event
      event_type: state_changed
      event_data:
        entity_id: input_button.start_dosing_pump
  action:
    - service: mqtt.publish
      data_template:
        topic: "/ReefRhythm/<unique_id>/dose"
        payload: >
          {
            "id": 1,
            "direction": {% if is_state('input_boolean.dosing_pump_direction', 'on') %}1{% else %}0{% endif %},
            "amount": {{ states('input_number.dosing_pump_amount') | float }},
            "duration": {{ states('input_number.dosing_pump_duration') | float }}
          }
  mode: single

there is a a little error that cost me a while :)

you name the helper with dosing_pump_remains but it should be dosing_pump_amount

After changing that, i am able to dose over HA

Have a nice day,
 
Last edited:

butch708

New Member
View Badges
Joined
May 15, 2024
Messages
17
Reaction score
4
Location
Germany
Rating - 0%
0   0   0
Thats the changed code, with ability to switch the pump id by a switch button.
Code:
- id: Start Dosing Pump
  alias: "Start Dosing Pump"
  trigger:
    - platform: event
      event_type: state_changed
      event_data:
        entity_id: input_button.start_dosing_pump
    - platform: state
      entity_id: input_boolean.change_pump
  action:
    - service: mqtt.publish
      data_template:
        topic: "/ReefRhythm/24587cda78dc/dose"
        payload: >
          {
            "id": {% if is_state('input_boolean.change_pump', 'on') %}2{% else %}1{% endif %},
            "direction": {% if is_state('input_boolean.dosing_pump_direction', 'on') %}1{% else %}0{% endif %},
            "amount": {{ states('input_number.dosing_pump_amount') | float(0) }},
            "duration": {{ states('input_number.dosing_pump_duration') | float(0) }}
          }
  mode: single

- id: Stop Dosing Pump
  alias: "Stop Dosing Pump"
  trigger:
    - platform: event
      event_type: state_changed
      event_data:
        entity_id: input_button.stop_dosing_pump
  action:
    - service: mqtt.publish
      data_template:
        topic: "/ReefRhythm/24587cda78dc/stop"
        payload: >
          {"id": {% if is_state('input_boolean.change_pump', 'on') %}2{% else %}1{% endif %},}
  mode: single
 
OP
OP
yury88

yury88

Active Member
View Badges
Joined
Oct 21, 2023
Messages
209
Reaction score
155
Location
indo-pacific
Rating - 0%
0   0   0
Hello Community,

As our project continues to grow and evolve, we strive to make it easier for everyone—users, contributors, and enthusiasts alike—to access, share, and contribute knowledge. With this goal in mind, I've made a significant update to how our project's wiki is managed.

Why the Change?

Previously, the wiki was directly tied to our main project repository. This setup limited the ability to collaboratively edit and improve the wiki without granting broader access than might be necessary or desirable. To foster a more collaborative environment and streamline the contribution process, I have moved the wiki to its own dedicated repository.

Benefits of a Dedicated Wiki Repository:

  • Easier Collaboration: Contributors can now directly edit, fix typos, add content, and refine existing documentation without needing access to the main codebase. This lowers barriers to entry for new contributors and allows for quicker updates and improvements.
  • Enhanced Control and Security: By separating the wiki from the main repository, we maintain better control over who can modify our code versus our documentation. This distinction ensures that contributions can be managed effectively and securely.
  • Focused Contributions: Contributors can focus solely on improving documentation without the overhead of understanding the entire code repository setup. This makes it particularly easy for those who specialize in technical writing or educational content to get involved.
I excited to invite our verified community members to become collaborators on the new wiki repository. Whether you're correcting a typo, adding a new tutorial, or sharing your project setup, your knowledge helps us all. If you're interested in contributing, please reach out to me to get involved.
 
OP
OP
yury88

yury88

Active Member
View Badges
Joined
Oct 21, 2023
Messages
209
Reaction score
155
Location
indo-pacific
Rating - 0%
0   0   0
Cool, i am in, if you let me :)

Welcome, invitation pending.

And actually, if you are playing with HA to use the same "card" for multiple pumps, I just added some useful settings to the to the publication in MQTT:

Screenshot 2024-05-31 151313.png
So topic /ReefRhythm/<unique id>/pump_settings contains settings:
"names" - pump names
"number" - number of pumps
"inversion" - inversion settings for pumps(0= not enabled)
"current" - current settings in mA
{
"current": [ 600, 800,1000, 1200, 1600,1800, 2000, 200, 400 ],
"names": [ "NO3", "PO4", "Ca", "KH", "Mg", "Iron", "Iodide", "Manganese", "Vinegar" ],
"number": 1,
"inversion": [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
}


This is a develop build that can be installed by putting url on OTA page:

Mostly I'm finished working on it and now verifying stability on long run:

- Notification refactoring- separate setting for Telegram/Whatsapp Notifications.
- Extended setting publications for MQTT
- Fixing some known bugs

Screenshot 2024-05-31 151305.png
 
OP
OP
yury88

yury88

Active Member
View Badges
Joined
Oct 21, 2023
Messages
209
Reaction score
155
Location
indo-pacific
Rating - 0%
0   0   0
I'm too stupid to set up mqtt. Maybe it would be a good idea to test the connection to mqtt server in the webgui.?
Yep, possible.

But before I want to make code refactoring. Some people not happy about code quality.
And its reasonable, project becomes too big to leave everything as is.
After refactoring more feature will follow.

And actually I'm going to add DC("Poor Man edition":) ) and "standard" stepper drivers support.
Mostly because I want to play with this tiny GROTHEN peristaltic pumps. Originally they are DC(1.5ml/min rated), but I made mod and install stepper motors:
IMG20240531141449.jpg
 

butch708

New Member
View Badges
Joined
May 15, 2024
Messages
17
Reaction score
4
Location
Germany
Rating - 0%
0   0   0
hello,

It would be cool if we could store the pH value of our liquids in the settings. This would be interesting for later automation and calculations of the dosing quantity.
 
OP
OP
yury88

yury88

Active Member
View Badges
Joined
Oct 21, 2023
Messages
209
Reaction score
155
Location
indo-pacific
Rating - 0%
0   0   0
hello,

It would be cool if we could store the pH value of our liquids in the settings. This would be interesting for later automation and calculations of the dosing quantity.
What transport do you prefer to use to transmit sensor values to the controller?

The easiest solution is to subscribe it to the MQTT topic with a sensor value.
But if you have a MQTT broker, usually you have a server where you can control dosing logic...


Some of this functionality will be added because I have plans to extend the project with PH Controller.
Actually full-assembled custom pcb board for this project is laying next to me right now)
So sensor values will be automatically shared via the ESP-NOW WiFi protocol. But there will be some fail-protection logic, like turning off the pump if the value exceeds PH 8.7.
 

Danchik

Community Member
View Badges
Joined
Jul 17, 2018
Messages
32
Reaction score
1
Location
UA
Rating - 0%
0   0   0
Oh, my bad- its a bug!
Thank you for reporting.
Already fixed in v0.9.5

You can upgrade firmware pushing the "starting upgrade" button on OTA page.
Give it some time like 10min to upgrade and than restart the page
And do not forget to to push "cancel rollback" on OTA page after firmware upgrade.

<hostname>.local will start working again after upgrade.
I just noticed that .local doesn't work through my cell phone, only through my home computer.
I tried it through the Google Chrome browser.

Or is it just me...?
 

butch708

New Member
View Badges
Joined
May 15, 2024
Messages
17
Reaction score
4
Location
Germany
Rating - 0%
0   0   0
What transport do you prefer to use to transmit sensor values to the controller?

The easiest solution is to subscribe it to the MQTT topic with a sensor value.
But if you have a MQTT broker, usually you have a server where you can control dosing logic...


Some of this functionality will be added because I have plans to extend the project with PH Controller.
Actually full-assembled custom pcb board for this project is laying next to me right now)
So sensor values will be automatically shared via the ESP-NOW WiFi protocol. But there will be some fail-protection logic, like turning off the pump if the value exceeds PH 8.7.
I have to think again about what would be the best way. I actually wanted to do the later calculations directly via HomeAssistant.

I already have a ph-ec-temp monitoring kit in home assistant, this is from microfire. What kind of one do you have?

I followed your
User Guide for Setting Up MQTT Sensors in Home Assistant

configuration.yaml
Code:
sensor: !include sensors.yaml
mqtt:
  sensor:
    - name: "ph_minus"
      state_topic: "/ReefRhythm/24587cda78dc/pump1"
      value_template: "{{ value_json.remain }}"
      unit_of_measurement: "ml"
      icon: "mdi:cup"
      json_attributes_topic: "/ReefRhythm/24587cda78dc/pump1"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}"

    - name: "ph_plus"
      state_topic: "/ReefRhythm/24587cda78dc/pump2"
      value_template: "{{ value_json.remain }}"
      unit_of_measurement: "ml"
      icon: "mdi:cup"
      json_attributes_topic: "/ReefRhythm/24587cda78dc/pump2"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}"

sensors.yaml
Code:
- platform: template
  sensors:
    ph_minus_pump1_dose:
      friendly_name: "PH-Minus Dosierung"
      icon_template: "{{ 'mdi:water-pump' }}"
      unit_of_measurement: "ml"
      value_template: "{{ state_attr('sensor.ph_minus_pump1', 'dose') }}"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_dose"
    ph_minus_pump1_storage:
      friendly_name: "PH-Minus Vorrat"
      icon_template: "{{ 'mdi:cup' }}"
      unit_of_measurement: "ml"
      value_template: "{{ state_attr('sensor.ph_minus_pump1', 'storage') }}"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_storage"
    ph_plus_pump2_dose:
      friendly_name: "PH-Plus Dosierung"
      icon_template: "{{ 'mdi:water-pump' }}"
      unit_of_measurement: "ml"
      value_template: "{{ state_attr('sensor.ph_plus_pump2', 'dose') }}"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_dose"
    ph_plus_pump2_storage:
      friendly_name: "PH-Plus Vorrat"
      icon_template: "{{ 'mdi:cup' }}"
      unit_of_measurement: "ml"
      value_template: "{{ state_attr('sensor.ph_plus_pump2', 'storage') }}"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_storage"

i get some errors in homeassistant.log
Code:
2024-06-04 08:31:00.108 ERROR (MainThread) [homeassistant.components.sensor] Platform template does not generate unique IDs. ID doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_dose is already used by sensor.ph_minus_pump1_dose - ignoring sensor.ph_plus_pump2_dose
2024-06-04 08:31:00.109 ERROR (MainThread) [homeassistant.components.sensor] Platform template does not generate unique IDs. ID doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_storage is already used by sensor.ph_minus_pump1_storage - ignoring sensor.ph_plus_pump2_storage
2024-06-04 08:31:01.687 ERROR (MainThread) [homeassistant.components.sensor] Platform mqtt does not generate unique IDs. ID doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }} already exists - ignoring sensor.ph_minus

Screenshot 2024-06-04 084804.png
Screenshot 2024-06-04 084708.png
 
OP
OP
yury88

yury88

Active Member
View Badges
Joined
Oct 21, 2023
Messages
209
Reaction score
155
Location
indo-pacific
Rating - 0%
0   0   0
dev build v1.1.23

OTA link for installation:

Mostly, it's a code refactoring of MQTT and notifications to stabilize everything on high load.

But MQTT got some small updates:
1)After connection or reconnection, the controller will automatically publish a "fake" dose with a volume of 0 ml.
{"dose": 0, "id": 1, "remain": 2500, "storage": 2500, "name": "NO3"}

It is needed to update the storage remaining on the MQTT server after reboots, for example.
It's useful to keep UI elements in HA up-to-date after restarts

2)"pump_settings" topic renamed to "settings":
{"storage": [2500, 0, 0, 0, 0, 0, 0, 0, 0], "names": ["NO3", "PO4", "Ca", "KH", "Mg", "Iron", "Iodide", "Manganese", "Vinegar"], "number": 1, "current": [600, 800, 1000, 1200, 1600, 1800, 2000, 200, 400], "inversion": [0, 0, 0, 0, 0, 0, 0, 0, 0]}
 
OP
OP
yury88

yury88

Active Member
View Badges
Joined
Oct 21, 2023
Messages
209
Reaction score
155
Location
indo-pacific
Rating - 0%
0   0   0
I have to think again about what would be the best way. I actually wanted to do the later calculations directly via HomeAssistant.

I already have a ph-ec-temp monitoring kit in home assistant, this is from microfire. What kind of one do you have?

I followed your
User Guide for Setting Up MQTT Sensors in Home Assistant

configuration.yaml
Code:
sensor: !include sensors.yaml
mqtt:
  sensor:
    - name: "ph_minus"
      state_topic: "/ReefRhythm/24587cda78dc/pump1"
      value_template: "{{ value_json.remain }}"
      unit_of_measurement: "ml"
      icon: "mdi:cup"
      json_attributes_topic: "/ReefRhythm/24587cda78dc/pump1"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}"

    - name: "ph_plus"
      state_topic: "/ReefRhythm/24587cda78dc/pump2"
      value_template: "{{ value_json.remain }}"
      unit_of_measurement: "ml"
      icon: "mdi:cup"
      json_attributes_topic: "/ReefRhythm/24587cda78dc/pump2"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}"

sensors.yaml
Code:
- platform: template
  sensors:
    ph_minus_pump1_dose:
      friendly_name: "PH-Minus Dosierung"
      icon_template: "{{ 'mdi:water-pump' }}"
      unit_of_measurement: "ml"
      value_template: "{{ state_attr('sensor.ph_minus_pump1', 'dose') }}"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_dose"
    ph_minus_pump1_storage:
      friendly_name: "PH-Minus Vorrat"
      icon_template: "{{ 'mdi:cup' }}"
      unit_of_measurement: "ml"
      value_template: "{{ state_attr('sensor.ph_minus_pump1', 'storage') }}"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_storage"
    ph_plus_pump2_dose:
      friendly_name: "PH-Plus Dosierung"
      icon_template: "{{ 'mdi:water-pump' }}"
      unit_of_measurement: "ml"
      value_template: "{{ state_attr('sensor.ph_plus_pump2', 'dose') }}"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_dose"
    ph_plus_pump2_storage:
      friendly_name: "PH-Plus Vorrat"
      icon_template: "{{ 'mdi:cup' }}"
      unit_of_measurement: "ml"
      value_template: "{{ state_attr('sensor.ph_plus_pump2', 'storage') }}"
      unique_id: "doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_storage"

i get some errors in homeassistant.log
Code:
2024-06-04 08:31:00.108 ERROR (MainThread) [homeassistant.components.sensor] Platform template does not generate unique IDs. ID doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_dose is already used by sensor.ph_minus_pump1_dose - ignoring sensor.ph_plus_pump2_dose
2024-06-04 08:31:00.109 ERROR (MainThread) [homeassistant.components.sensor] Platform template does not generate unique IDs. ID doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}_storage is already used by sensor.ph_minus_pump1_storage - ignoring sensor.ph_plus_pump2_storage
2024-06-04 08:31:01.687 ERROR (MainThread) [homeassistant.components.sensor] Platform mqtt does not generate unique IDs. ID doser_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }} already exists - ignoring sensor.ph_minus
you need to set unique ID for each sensor.
sensor:
- name: "ph_minus"

unique_id: "doser_ph_minus_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True) | lower }}"

- name: "ph_plus"
unique_id: "doser_ph_plus_{{ value_json.name | replace(' ', '_') | regex_replace('[^a-z0-9_]', '', ignorecase=True)
 

butch708

New Member
View Badges
Joined
May 15, 2024
Messages
17
Reaction score
4
Location
Germany
Rating - 0%
0   0   0
I want to create a new page on the wiki these days, for setting up a two head(ph+,ph-) ph doser. Can you create a folder for 3d printing files and do i have the permission to upload files?

do you have discord or similar?
 
OP
OP
yury88

yury88

Active Member
View Badges
Joined
Oct 21, 2023
Messages
209
Reaction score
155
Location
indo-pacific
Rating - 0%
0   0   0
I want to create a new page on the wiki these days, for setting up a two head(ph+,ph-) ph doser. Can you create a folder for 3d printing files and do i have the permission to upload files?

do you have discord or similar?
Wiki mostly supports only graphical(video also) file uploads.
3D printing files are better to store on some specialized portals like thingiverse.com.
I suggest just include a thingiverse link to your project on wiki

And no, I don't have discord, bug mostly I often online here)
And all Github reciprocity has "Discussion" function
 

WHITE BUCKET CHALLENGE : How CLEAR do you think your water is in your reef aquarium? Show us your water!

  • Crystal Clear

    Votes: 61 39.4%
  • Mostly clear with a tint of yellow

    Votes: 80 51.6%
  • More yellow than clear

    Votes: 6 3.9%
  • YUCKY YELLOW

    Votes: 2 1.3%
  • Other (please explain)

    Votes: 6 3.9%
Back
Top