Skip to content

Commit

Permalink
Merge pull request sebirdman#46 from njobrien1006/CookCycleUpdate
Browse files Browse the repository at this point in the history
Cook cycle update
  • Loading branch information
njobrien1006 authored May 29, 2023
2 parents a4d5c93 + 2dca070 commit 104881e
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 50 deletions.
42 changes: 35 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ Platform | Description
![grill][grillimg]
![probe][probeimg]

## Installation (HACS)

1. Add this repository to HACS
2. Search for Traeger in HACS

## Installation (Manual)

1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`).
Expand All @@ -32,12 +37,12 @@ Platform | Description
7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Traeger"

## Platform Details
Some of the platforms are fairly self explanatory, others could use a little more explaining. Below are more details on some of those platforms.
Some of the platforms are fairly self-explanatory, others could use a little more explaining. Below are more details on some of those platforms.
### Grill State Sensor
This sensor aligns with the status values in the Traeger app.
State | Description
-- | --
`offline` | Powered off (or not accesible)
`offline` | Powered off (or not accessible)
`sleeping` | Standing by (power switch on, screen off)
`idle` | Standing by (power switch on, screen on)
`igniting` | Igniting the fire pot
Expand All @@ -46,7 +51,7 @@ State | Description
`custom_cook` | Cooking mode, using preset cook cycle
`cool_down` | Cool down cycle
`shutdown` | Cool down cycle complete, heading to sleep
`unknown` | Unkown state, report to developers
`unknown` | Unknown state, report to developers

### Heating State Sensor
This sensor tries to provide more useful insight into the heating status of the grill. Many of these values can be trigger off of to provide notifications that are not available in the Traeger app.
Expand All @@ -69,12 +74,35 @@ State | Description
`set` | Probe target temperature **is** set
`close` | Probe temperature is within 5°F of target temperature
`at_temp` | Probe alarm has fired
`fell_out` | Probe probably fell out of the meat (Probe temperature is greater that 215°F)
`fell_out` | Probe probably fell out of the meat (Probe temperature is greater than 215°F)

### Cook Cycle Number
This number indicates the current cook step. It runs the cook cycle as called by the `set_custom_cook` service.
State | Description
-- | --
`number.cook_cycl_step` | Full list of cook steps. Must be set by `set_custom_cook`.
`number.prev_step` | The previous step.
`number.curr_step` | The current step.
`number.next_step` | The next step.

### set_custom_cook Service
Service to set the list of steps for a cook sequence. The service must be against `number.____cook_cycle`.

See `Developer Tools : SERVICES : Traeger: Set Cook Cycle` for a default cook steps list.
Step Type | Description
-- | --
`service[].set_temp` | Set Grill Temp. *Only up to your grill's MaxTemp.
`service[].smoke` | Set Smoke Mode 1 or 0. *Only Avail if grill supports.
`service[].keepwarm` | Set keepwarm, Mode 1 or 0.
`service[].time_set` | Set Timer in Minutes.
`service[].use_timer` | Use Timer to Advance State. *Only applies to current state.
`service[].min_delta` | Min DELTA temp between Grill and Probe. *Requires `max_grill_delta_temp`.
`service[].max_grill_delta_temp` | Max Temp it will increase to from probe `min_delta`. *Requires `min_delta`.
`service[].act_temp_adv` | Grill Temp at which the State will advance.
`service[].probe_act_temp_adv` | Probe Temp at which the State will advance.
`service[].shutdown` | Call Grill Shutdown.

## Installation (HACS)

1. Add this repository to HACS
2. Search for Traeger in HACS

## Configuration is done in the UI

Expand Down
102 changes: 74 additions & 28 deletions custom_components/traeger/number.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Number/Timer platform for Traeger."""
import re
import voluptuous as vol
from homeassistant.components.number import NumberEntity
from homeassistant.helpers import entity_platform
Expand All @@ -13,7 +14,12 @@
}

from .const import (
DOMAIN,)
DOMAIN,
GRILL_MODE_COOL_DOWN,
GRILL_MODE_SLEEPING,
GRILL_MODE_SHUTDOWN,
GRILL_MODE_IDLE,
)

_LOGGER: logging.Logger = logging.getLogger(__package__)

Expand Down Expand Up @@ -74,14 +80,21 @@ def native_native_step(self):
@property
def native_value(self):
if self.grill_state is None:
return 0
self.num_value = 0
return self.num_value
if self.num_value > len(self.cook_cycle):
_LOGGER.info(f"B.Cook Cycles out of indexes.")
self.num_value = 0
if self.num_value > 0 and not (4 <= self.grill_state["system_status"] <=
6):
return self.num_value
name = re.sub('[^A-Za-z0-9]+', '', self.grill_details["friendlyName"])
_LOGGER.info(f"Name: {name}")
if self.num_value > 0 and self.grill_state["system_status"] in [
GRILL_MODE_COOL_DOWN, GRILL_MODE_SLEEPING, GRILL_MODE_SHUTDOWN,
GRILL_MODE_IDLE
]:
_LOGGER.info(f"Steps not available when not cooking. Revert to 0.")
#self.num_value = 0 This causes issues when/if the grill looses connection
self.num_value = 0
return self.num_value
########################################################################
#Scan for next step advance
if self.num_value > 0 and self.num_value == self.old_num_value:
Expand Down Expand Up @@ -110,48 +123,81 @@ def native_value(self):
"set"] - curstep["min_delta"]:
set_temp = self.grill_state["set"] + 5
self.hass.async_create_task(
self.client.set_temperature(self.grill_id,
round(set_temp)))
self.hass.services.async_call(
"climate", "set_temperature", {
"entity_id":
f"climate.{self.grill_id}_climate",
"temperature":
round(set_temp)
}, False))
########################################################################
#Implement next step
if self.num_value > 0 and self.num_value != self.old_num_value: #Only hit once per step.
curstep = self.cook_cycle[self.num_value - 1]
if "time_set" in curstep:
self.hass.async_create_task(
self.client.set_timer_sec(self.grill_id,
round(curstep["time_set"])))
self.hass.services.async_call(
"number", "set_value", {
"entity_id": f"number.{self.grill_id}_cook_timer",
"value": round(curstep["time_set"])
}, False))
if "probe_set_temp" in curstep:
if curstep["max_grill_delta_temp"] > self.grill_limits[
"max_grill_temp"]:
curstep["max_grill_delta_temp"] = self.grill_limits[
"max_grill_temp"]
name = re.sub('[^A-Za-z0-9]+', '',
self.grill_details["friendlyName"])
self.hass.async_create_task(
self.client.set_probe_temperature(
self.grill_id, round(curstep["probe_set_temp"])))
self.hass.services.async_call(
"climate", "set_temperature", {
"entity_id": f"climate.{name.lower()}_probe_p0",
"temperature": round(curstep["probe_set_temp"])
}, False))
if "set_temp" in curstep:
self.hass.async_create_task(
self.client.set_temperature(self.grill_id,
round(curstep["set_temp"])))
self.hass.services.async_call(
"climate", "set_temperature", {
"entity_id": f"climate.{self.grill_id}_climate",
"temperature": round(curstep["set_temp"])
}, False))
if "smoke" in curstep:
if self.grill_state["set"] <= 225 and self.grill_features[
"super_smoke_enabled"] == 1:
if self.grill_features[
"super_smoke_enabled"] == 1 and self.grill_state[
"smoke"] != curstep["smoke"] and self.grill_state[
"set"] <= 225:
if curstep["smoke"] == 1:
self.hass.async_create_task(
self.client.set_switch(self.grill_id, 20))
self.hass.services.async_call(
"switch", "turn_on",
{"entity_id": f"switch.{self.grill_id}_smoke"},
False))
else:
self.hass.async_create_task(
self.client.set_switch(self.grill_id, 21))
self.hass.services.async_call(
"switch", "turn_off",
{"entity_id": f"switch.{self.grill_id}_smoke"},
False))
if "keepwarm" in curstep:
if curstep["keepwarm"] == 1:
self.hass.async_create_task(
self.client.set_switch(self.grill_id, 18))
else:
self.hass.async_create_task(
self.client.set_switch(self.grill_id, 19))
if self.grill_state["keepwarm"] != curstep["keepwarm"]:
if curstep["keepwarm"] == 1:
self.hass.async_create_task(
self.hass.services.async_call(
"switch", "turn_on", {
"entity_id":
f"switch.{self.grill_id}_keepwarm"
}, False))
else:
self.hass.async_create_task(
self.hass.services.async_call(
"switch", "turn_off", {
"entity_id":
f"switch.{self.grill_id}_keepwarm"
}, False))
if "shutdown" in curstep:
if curstep["shutdown"] == 1:
self.hass.async_create_task(
self.client.shutdown_grill(self.grill_id))
self.hass.services.async_call(
"climate", "set_hvac_mode", {
"entity_id": f"climate.{self.grill_id}_climate",
"hvac_mode": "cool"
}, False))
self.num_value = 0
self.old_num_value = self.num_value
_LOGGER.debug(f"CookCycle Steps:{self.cook_cycle}")
Expand Down
37 changes: 22 additions & 15 deletions custom_components/traeger/services.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@

set_custom_cook:
name: Set Cook Cycle
description: Set Custom Cook Cycle Steps
fields:
entity_id:
description: "Number Entity that serves Custom Cook Steps."
example: "'number.abcdefghi123_cook_cycle'"
name: Entity
required: true
selector:
entity:
integration: traeger
domain: number
steps:
description: |
Steps to perform.
`probe_alarm_fired` will progress the step =OR=
(`cook_timer_complete` AND `use_timer`) =OR=
(`act_temp_adv` < grill temp) =OR=
(`probe_act_temp_adv` < probe temp)
This Service only allows `Steps` Parameter. The other Parameters need to be nested within steps. See example (FILL EXAMPLE DATA), or /config/custom_components/traeger/services.yaml for more info.
List of steps to perform.
required: true
example:
default:
- #1 Set temp and smoke, advance on probe fired, or act_temp_adv
set_temp: 180 #Set grill temp
smoke: 1 #S.Smoke if applicable
smoke: 1 #S.Smoke if applicable
act_temp_adv: 170 #Move to next step at this act temp
- #2 PRE-HEAT....Set timer and use timer to advance. #Probe fire would also advance it.
time_set: 900 #Set timer
use_timer: 1 #If set we use the timer to progress if set to zero it won't progress on timer.
use_timer: 15 #If set we use the timer to progress if set to zero it won't progress on timer.
- #3 Set Probe Setpoint and Referance timer. Advance on probe_act_temp_adv (since it is lower than probe setpoint Step #2).
# `min_delta` AND `max_grill_delta_temp` can be used to increase grill temp within the step.
probe_set_temp: 205 #Probe Temp
time_set: 64800 #Set timer in SECONDS but no `use_timer` so this is ref. only.
time_set: 1080 #Set timer in SECONDS but no `use_timer` so this is ref. only.
min_delta: 30 #Min Delta that the Grill temp will stay at in relation to probe.
max_grill_delta_temp: 225 #Required for min_delta
probe_act_temp_adv: 160 #adv the step on probe act temp
Expand All @@ -43,16 +42,24 @@ set_custom_cook:
probe_act_temp_adv: 206 #Adv if probe registered over setpoint in step 2...safety.
- #6 Set temp to where the probe is @. Set timer. Advance on timer complete
set_temp: 205 #Go down to probe temp
time_set: 900 #Wait 15 minutes for somebody to tell me otherwise
time_set: 15 #Wait 15 minutes for somebody to tell me otherwise
use_timer: 1 #Adv on timer
- #7 Set for keep warm. Set timer. Advance on timer complete
keepwarm: 1 #Go down to probe temp
time_set: 15 #Wait 15 minutes for somebody to tell me otherwise
use_timer: 1 #Adv on timer
- #7 Shutdown the grill if the timer is not cancelled.
- #8 Shutdown the grill if the timer is not cancelled.
shutdown: 1 #Nobody aborted...shutdown.
selector:
object:
set_temp:
description: "Set Grill Temp. *Only up to your grill's MaxTemp."
smoke:
description: "Set Smoke Mode 1 or 0. *Only Avail if grill supports"
keepwarm:
description: "Set keepwarm, Mode 1 or 0."
time_set:
description: "Set Timer."
description: "Set Timer in Minutes."
use_timer:
description: "Use Timer to Advance State. *Only applies to current state."
min_delta:
Expand Down

0 comments on commit 104881e

Please sign in to comment.