mirror of
https://github.com/Xevion/go-ha.git
synced 2026-01-31 04:24:27 -06:00
rename to DisabledWhen and EnabledWhen
This commit is contained in:
+6
-6
@@ -102,12 +102,12 @@ func (b eventListenerBuilder3) ExceptionRange(start, end time.Time) eventListene
|
||||
Enable this listener only when the current state of {entityId} matches {state}.
|
||||
If there is a network error while retrieving state, the listener runs if {runOnNetworkError} is true.
|
||||
*/
|
||||
func (b eventListenerBuilder3) EnabledEntity(entityId, state string, runOnNetworkError bool) eventListenerBuilder3 {
|
||||
func (b eventListenerBuilder3) EnabledWhen(entityId, state string, runOnNetworkError bool) eventListenerBuilder3 {
|
||||
if entityId == "" || state == "" {
|
||||
panic(fmt.Sprintf("Either entityId or state is empty in eventListener.EnabledEntity entityId='%s' state='%s' runOnNetworkError='%t'", entityId, state, runOnNetworkError))
|
||||
panic(fmt.Sprintf("Either entityId or state is empty in eventListener EnabledWhen entityId='%s' state='%s' runOnNetworkError='%t'", entityId, state, runOnNetworkError))
|
||||
}
|
||||
if b.eventListener.enabledEntity != "" {
|
||||
panic(fmt.Sprintf("You can't use EnabledEntity and DisabledEntity together. Error occurred while setting EnabledEntity entityId=%s state=%s runOnNetworkError=%t", entityId, state, runOnNetworkError))
|
||||
panic(fmt.Sprintf("You can't use EnabledWhen and DisabledWhen together. Error occurred while setting EnabledWhen entityId=%s state=%s runOnNetworkError=%t", entityId, state, runOnNetworkError))
|
||||
}
|
||||
b.eventListener.enabledEntity = entityId
|
||||
b.eventListener.enabledEntityState = state
|
||||
@@ -119,12 +119,12 @@ func (b eventListenerBuilder3) EnabledEntity(entityId, state string, runOnNetwor
|
||||
Disable this listener when the current state of {entityId} matches {state}.
|
||||
If there is a network error while retrieving state, the listener runs if {runOnNetworkError} is true.
|
||||
*/
|
||||
func (b eventListenerBuilder3) DisabledEntity(entityId, state string, runOnNetworkError bool) eventListenerBuilder3 {
|
||||
func (b eventListenerBuilder3) DisabledWhen(entityId, state string, runOnNetworkError bool) eventListenerBuilder3 {
|
||||
if entityId == "" || state == "" {
|
||||
panic(fmt.Sprintf("Either entityId or state is empty in eventListener.EnabledEntity entityId='%s' state='%s' runOnNetworkError='%t'", entityId, state, runOnNetworkError))
|
||||
panic(fmt.Sprintf("Either entityId or state is empty in eventListener EnabledWhen entityId='%s' state='%s' runOnNetworkError='%t'", entityId, state, runOnNetworkError))
|
||||
}
|
||||
if b.eventListener.enabledEntity != "" {
|
||||
panic(fmt.Sprintf("You can't use EnabledEntity and DisabledEntity together. Error occurred while setting DisabledEntity entityId=%s state=%s runOnNetworkError=%t", entityId, state, runOnNetworkError))
|
||||
panic(fmt.Sprintf("You can't use EnabledWhen and DisabledWhen together. Error occurred while setting DisabledWhen entityId=%s state=%s runOnNetworkError=%t", entityId, state, runOnNetworkError))
|
||||
}
|
||||
b.eventListener.disabledEntity = entityId
|
||||
b.eventListener.disabledEntityState = state
|
||||
|
||||
Reference in New Issue
Block a user