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

Add Homeassistant Discovery Feature #360

Merged
merged 6 commits into from
Sep 27, 2023

Conversation

dafes
Copy link
Contributor

@dafes dafes commented Jun 5, 2023

  • Updated MQTT.h to add core and supporting functions
  • Updated userConfig_sample.h to introduce new options:
    • #define MQTT_HASSIO_SUPPORT 0 // Enables the Homeassistant Auto Discovery Feature
    • #define MQTT_HASSIO_DISCOVERY_PREFIX "homeassistant" // Homeassistant Auto Discovery Prefix
  • Implemented a ToDo inside MQTT and also cleaned it a bit
  • Established a Task which runs every n Seconds to update Hassio Discovery defined by const unsigned long HomeAssistantDiscoveryExecutionInterval = 300000; in main.cpp

dafes and others added 2 commits June 1, 2023 15:50
cleaned mqtt.h

updated references

updated mqtt lib

added correct ha discovery function

updated hassio_discovery function

updated hassio functions
@dafes dafes changed the title Add Homeassistant Discovery Feature DRAFT: Add Homeassistant Discovery Feature Jun 5, 2023
@dafes dafes changed the title DRAFT: Add Homeassistant Discovery Feature Add Homeassistant Discovery Feature Jun 5, 2023
@dafes dafes closed this Aug 14, 2023
@einarhauks
Copy link
Contributor

Why was the pull request closed without merging into master?

@dafes dafes reopened this Aug 14, 2023
@dafes
Copy link
Contributor Author

dafes commented Aug 14, 2023

The PR is open for 2 Months. @einarhauks if you tested it please confirm it here so this can finally be merged or closed

@LoQue90
Copy link
Member

LoQue90 commented Aug 14, 2023

It's only @dafes and me that I know that uses home assistant.
I just had this PR running once, had no time at all besides live, sending out pcbs and giving support.
So any other testing is highly welcome and appreciated!
@einarhauks go for feedback pls
@dafes could you have a look at @339 and maybe add this here.
I'm at home the next days, going to flash ist tomorrow on my main mashine.

@LoQue90
Copy link
Member

LoQue90 commented Aug 28, 2023

@einarhauks did you had time to test?

@einarhauks
Copy link
Contributor

@LoQue90 No, sorry. I’ll try to test it soon, give to the end of the week :)

@einarhauks
Copy link
Contributor

Tested and it looks good. Editing configuration from Home Assistant works as expected and temperature is reported

I suggest improving the texts:
DiscoveryObject brewSetpoint = GenerateNumberDevice("brewSetpoint", "Brew setpoint", BREW_SETPOINT_MIN, BREW_SETPOINT_MAX, 0.1, "°C"); DiscoveryObject steamSetPoint = GenerateNumberDevice("steamSetpoint", "Steam setpoint", STEAM_SETPOINT_MIN, STEAM_SETPOINT_MAX, 0.1, "°C"); DiscoveryObject brewTempOffset = GenerateNumberDevice("brewTempOffset", "Brew Temp. Offset", BREW_TEMP_OFFSET_MIN, BREW_TEMP_OFFSET_MAX, 0.1, "°C"); DiscoveryObject brewPidDelay = GenerateNumberDevice("brewPidDelay", "Brew Pid Delay", BREW_PID_DELAY_MIN, BREW_PID_DELAY_MAX, 0.1, ""); DiscoveryObject startKp = GenerateNumberDevice("startKp", "Start kP", PID_KP_START_MIN, PID_KP_START_MAX, 0.1, ""); DiscoveryObject startTn = GenerateNumberDevice("startTn", "Start Tn", PID_TN_START_MIN, PID_TN_START_MAX, 0.1, ""); DiscoveryObject steamKp = GenerateNumberDevice("steamKp", "Start Kp", PID_KP_STEAM_MIN, PID_KP_STEAM_MAX, 0.1, ""); DiscoveryObject aggKp = GenerateNumberDevice("aggKp", "aggKp", PID_KP_REGULAR_MIN, PID_KP_REGULAR_MAX, 0.1, ""); DiscoveryObject aggTn = GenerateNumberDevice("aggTn", "aggTn", PID_TN_REGULAR_MIN, PID_TN_REGULAR_MAX, 0.1, ""); DiscoveryObject aggTv = GenerateNumberDevice("aggTv", "aggTv", PID_TV_REGULAR_MIN, PID_TV_REGULAR_MAX, 0.1, ""); DiscoveryObject aggIMax = GenerateNumberDevice("aggIMax", "aggIMax", PID_I_MAX_REGULAR_MIN, PID_I_MAX_REGULAR_MAX, 0.1, ""); DiscoveryObject brewtime = GenerateNumberDevice("brewtime", "Brew time", BREW_TIME_MIN, BREW_TIME_MAX, 0.1, "s"); // Sensor Devices DiscoveryObject actual_temperature = GenerateSensorDevice("temperature", "Boiler Temperature"); DiscoveryObject heaterPower = GenerateSensorDevice("heaterPower", "Heater Power", "ms", "power_factor"); // Switch Devices DiscoveryObject pidOn = GenerateSwitchDevice("pidON", "Use PID"); DiscoveryObject steamON = GenerateSwitchDevice("steamON", "Steam"); DiscoveryObject backflushON = GenerateSwitchDevice("backflushON", "Backflush"); DiscoveryObject startUsePonM = GenerateSwitchDevice("startUsePonM", "Use PonM");

* @brief Send MQTT Homeassistant Discovery Messages
* @return 0 if successful, MQTT connection error code if failed to send messages
*/
int sendHASSIODiscoveryMsg() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest improving the texts
DiscoveryObject brewSetpoint = GenerateNumberDevice("brewSetpoint", "Brew setpoint", BREW_SETPOINT_MIN, BREW_SETPOINT_MAX, 0.1, "°C"); DiscoveryObject steamSetPoint = GenerateNumberDevice("steamSetpoint", "Steam setpoint", STEAM_SETPOINT_MIN, STEAM_SETPOINT_MAX, 0.1, "°C"); DiscoveryObject brewTempOffset = GenerateNumberDevice("brewTempOffset", "Brew Temp. Offset", BREW_TEMP_OFFSET_MIN, BREW_TEMP_OFFSET_MAX, 0.1, "°C"); DiscoveryObject brewPidDelay = GenerateNumberDevice("brewPidDelay", "Brew Pid Delay", BREW_PID_DELAY_MIN, BREW_PID_DELAY_MAX, 0.1, ""); DiscoveryObject startKp = GenerateNumberDevice("startKp", "Start kP", PID_KP_START_MIN, PID_KP_START_MAX, 0.1, ""); DiscoveryObject startTn = GenerateNumberDevice("startTn", "Start Tn", PID_TN_START_MIN, PID_TN_START_MAX, 0.1, ""); DiscoveryObject steamKp = GenerateNumberDevice("steamKp", "Start Kp", PID_KP_STEAM_MIN, PID_KP_STEAM_MAX, 0.1, ""); DiscoveryObject aggKp = GenerateNumberDevice("aggKp", "aggKp", PID_KP_REGULAR_MIN, PID_KP_REGULAR_MAX, 0.1, ""); DiscoveryObject aggTn = GenerateNumberDevice("aggTn", "aggTn", PID_TN_REGULAR_MIN, PID_TN_REGULAR_MAX, 0.1, ""); DiscoveryObject aggTv = GenerateNumberDevice("aggTv", "aggTv", PID_TV_REGULAR_MIN, PID_TV_REGULAR_MAX, 0.1, ""); DiscoveryObject aggIMax = GenerateNumberDevice("aggIMax", "aggIMax", PID_I_MAX_REGULAR_MIN, PID_I_MAX_REGULAR_MAX, 0.1, ""); DiscoveryObject brewtime = GenerateNumberDevice("brewtime", "Brew time", BREW_TIME_MIN, BREW_TIME_MAX, 0.1, "s"); // Sensor Devices DiscoveryObject actual_temperature = GenerateSensorDevice("temperature", "Boiler Temperature"); DiscoveryObject heaterPower = GenerateSensorDevice("heaterPower", "Heater Power", "ms", "power_factor"); // Switch Devices DiscoveryObject pidOn = GenerateSwitchDevice("pidON", "Use PID"); DiscoveryObject steamON = GenerateSwitchDevice("steamON", "Steam"); DiscoveryObject backflushON = GenerateSwitchDevice("backflushON", "Backflush"); DiscoveryObject startUsePonM = GenerateSwitchDevice("startUsePonM", "Use PonM");

Copy link
Contributor

@einarhauks einarhauks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also tested building and uploading to my machine, works as expected

@einarhauks
Copy link
Contributor

@LoQue90 I've tested this and verified, now someone with merge review/rights need to take the next step

@murmeltier08
Copy link
Contributor

I can merge it, but i do not have tested it.

@dafes
Copy link
Contributor Author

dafes commented Sep 27, 2023

I can merge it, but i do not have tested it.

worked on my machine :D

@LoQue90
Copy link
Member

LoQue90 commented Sep 27, 2023

adding the new names from @einarhauks would be nice
add moving the option to enable/disable the feature to the website instead of the userconfig would be nice.
ist running on my mashine for a while

@dafes
Copy link
Contributor Author

dafes commented Sep 27, 2023

adding the new names from @einarhauks would be nice add moving the option to enable/disable the feature to the website instead of the userconfig would be nice. ist running on my mashine for a while

let us merge the PR first. You or anybody can create a PR with these suggestions.
I can try to add the name change but not sure when i will have time for this. Unfortunately i'm a bit overwhelmed with work at the moment :(

@dafes
Copy link
Contributor Author

dafes commented Sep 27, 2023

updated
@einarhauks @LoQue90

@LoQue90
Copy link
Member

LoQue90 commented Sep 27, 2023

then go for merge and let us improve it later!
@murmeltier08

@murmeltier08 murmeltier08 merged commit 5758cdf into rancilio-pid:master Sep 27, 2023
1 check passed
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

Successfully merging this pull request may close these issues.

4 participants