mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 09:01:49 +00:00 
			
		
		
		
	Compare commits
	
		
			82 Commits
		
	
	
		
			2022.6.0b1
			...
			2022.6.0
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					8c9948bb56 | ||
| 
						 | 
					2d1abaa68e | ||
| 
						 | 
					664a3df0b4 | ||
| 
						 | 
					9ff893881c | ||
| 
						 | 
					94f6c6861a | ||
| 
						 | 
					b1d614e6c4 | ||
| 
						 | 
					7fceb070e5 | ||
| 
						 | 
					5c7c0834c0 | ||
| 
						 | 
					f3a25de11d | ||
| 
						 | 
					041bef8bcd | ||
| 
						 | 
					6e83790308 | ||
| 
						 | 
					d2d4eb4eae | ||
| 
						 | 
					5942a3898c | ||
| 
						 | 
					93421f0fa7 | ||
| 
						 | 
					77f322166e | ||
| 
						 | 
					f3f6e54818 | ||
| 
						 | 
					fb0fec1f25 | ||
| 
						 | 
					b66af9fb4d | ||
| 
						 | 
					6617d576a7 | ||
| 
						 | 
					420dacb22d | ||
| 
						 | 
					ae2f6ad4d1 | ||
| 
						 | 
					2c28d79bf8 | ||
| 
						 | 
					993044c870 | ||
| 
						 | 
					a8c1b63edb | ||
| 
						 | 
					db7d946e1b | ||
| 
						 | 
					fc7348d46d | ||
| 
						 | 
					8be2456c7e | ||
| 
						 | 
					bb5f7249a6 | ||
| 
						 | 
					fc94a5d0ee | ||
| 
						 | 
					24029cc918 | ||
| 
						 | 
					9a9d5964ee | ||
| 
						 | 
					4e4a512107 | ||
| 
						 | 
					0729ed538e | ||
| 
						 | 
					24b75b7ed6 | ||
| 
						 | 
					ec3618ecb8 | ||
| 
						 | 
					792a24f38d | ||
| 
						 | 
					652e8a015b | ||
| 
						 | 
					1ef6fd8fb0 | ||
| 
						 | 
					942b0de7fd | ||
| 
						 | 
					859cca49d1 | ||
| 
						 | 
					8f7ff25624 | ||
| 
						 | 
					97aca8e54c | ||
| 
						 | 
					95acf19067 | ||
| 
						 | 
					3d0899aa58 | ||
| 
						 | 
					138d6e505b | ||
| 
						 | 
					2748e6ba29 | ||
| 
						 | 
					dbd4e927d8 | ||
| 
						 | 
					e73d47918f | ||
| 
						 | 
					b881bc071e | ||
| 
						 | 
					1d0395d1c7 | ||
| 
						 | 
					616c787e37 | ||
| 
						 | 
					0c4de2bc97 | ||
| 
						 | 
					c2f5ac9eba | ||
| 
						 | 
					5764c988af | ||
| 
						 | 
					ccc2fbfd67 | ||
| 
						 | 
					10b4adb8e6 | ||
| 
						 | 
					83b7181bcb | ||
| 
						 | 
					8886b7e141 | ||
| 
						 | 
					7dcc4d030b | ||
| 
						 | 
					b9398897c1 | ||
| 
						 | 
					657b1c60ae | ||
| 
						 | 
					dc54b17778 | ||
| 
						 | 
					1fb214165b | ||
| 
						 | 
					81b2fd78f5 | ||
| 
						 | 
					69002fb1e6 | ||
| 
						 | 
					75332a752d | ||
| 
						 | 
					09ed1aed93 | ||
| 
						 | 
					53d3718028 | ||
| 
						 | 
					2b5dce5232 | ||
| 
						 | 
					9ad84150aa | ||
| 
						 | 
					c0523590b4 | ||
| 
						 | 
					c7f091ab10 | ||
| 
						 | 
					7479e0aada | ||
| 
						 | 
					5bbee1a1fe | ||
| 
						 | 
					bdb9546ca3 | ||
| 
						 | 
					46af4cad6e | ||
| 
						 | 
					76a238912b | ||
| 
						 | 
					909a526967 | ||
| 
						 | 
					cd6f4fb93f | ||
| 
						 | 
					c19458696e | ||
| 
						 | 
					318b930e9f | ||
| 
						 | 
					9296a078a7 | 
@@ -25,7 +25,7 @@ OVERSAMPLING_OPTIONS = {
 | 
				
			|||||||
    "4X": Oversampling.OVERSAMPLING_X4,
 | 
					    "4X": Oversampling.OVERSAMPLING_X4,
 | 
				
			||||||
    "8X": Oversampling.OVERSAMPLING_X8,
 | 
					    "8X": Oversampling.OVERSAMPLING_X8,
 | 
				
			||||||
    "16X": Oversampling.OVERSAMPLING_X16,
 | 
					    "16X": Oversampling.OVERSAMPLING_X16,
 | 
				
			||||||
    "32x": Oversampling.OVERSAMPLING_X32,
 | 
					    "32X": Oversampling.OVERSAMPLING_X32,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
IIRFilter = bmp3xx_ns.enum("IIRFilter")
 | 
					IIRFilter = bmp3xx_ns.enum("IIRFilter")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,6 +51,22 @@ void I2SAudioMediaPlayer::control(const media_player::MediaPlayerCall &call) {
 | 
				
			|||||||
          this->state = media_player::MEDIA_PLAYER_STATE_PAUSED;
 | 
					          this->state = media_player::MEDIA_PLAYER_STATE_PAUSED;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					      case media_player::MEDIA_PLAYER_COMMAND_VOLUME_UP: {
 | 
				
			||||||
 | 
					        float new_volume = this->volume + 0.1f;
 | 
				
			||||||
 | 
					        if (new_volume > 1.0f)
 | 
				
			||||||
 | 
					          new_volume = 1.0f;
 | 
				
			||||||
 | 
					        this->set_volume_(new_volume);
 | 
				
			||||||
 | 
					        this->unmute_();
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      case media_player::MEDIA_PLAYER_COMMAND_VOLUME_DOWN: {
 | 
				
			||||||
 | 
					        float new_volume = this->volume - 0.1f;
 | 
				
			||||||
 | 
					        if (new_volume < 0.0f)
 | 
				
			||||||
 | 
					          new_volume = 0.0f;
 | 
				
			||||||
 | 
					        this->set_volume_(new_volume);
 | 
				
			||||||
 | 
					        this->unmute_();
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  this->publish_state();
 | 
					  this->publish_state();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -178,7 +178,8 @@ void Logger::pre_setup() {
 | 
				
			|||||||
        Serial1.setDebugOutput(ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE);
 | 
					        Serial1.setDebugOutput(ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
#if defined(USE_ESP32) && !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32S2)
 | 
					#if defined(USE_ESP32) && !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32S2) && \
 | 
				
			||||||
 | 
					    !defined(USE_ESP32_VARIANT_ESP32S3)
 | 
				
			||||||
      case UART_SELECTION_UART2:
 | 
					      case UART_SELECTION_UART2:
 | 
				
			||||||
        this->hw_serial_ = &Serial2;
 | 
					        this->hw_serial_ = &Serial2;
 | 
				
			||||||
        Serial2.begin(this->baud_rate_);
 | 
					        Serial2.begin(this->baud_rate_);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,6 +29,17 @@ PauseAction = media_player_ns.class_(
 | 
				
			|||||||
StopAction = media_player_ns.class_(
 | 
					StopAction = media_player_ns.class_(
 | 
				
			||||||
    "StopAction", automation.Action, cg.Parented.template(MediaPlayer)
 | 
					    "StopAction", automation.Action, cg.Parented.template(MediaPlayer)
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					VolumeUpAction = media_player_ns.class_(
 | 
				
			||||||
 | 
					    "VolumeUpAction", automation.Action, cg.Parented.template(MediaPlayer)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					VolumeDownAction = media_player_ns.class_(
 | 
				
			||||||
 | 
					    "VolumeDownAction", automation.Action, cg.Parented.template(MediaPlayer)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					VolumeSetAction = media_player_ns.class_(
 | 
				
			||||||
 | 
					    "VolumeSetAction", automation.Action, cg.Parented.template(MediaPlayer)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CONF_VOLUME = "volume"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async def setup_media_player_core_(var, config):
 | 
					async def setup_media_player_core_(var, config):
 | 
				
			||||||
@@ -45,9 +56,7 @@ async def register_media_player(var, config):
 | 
				
			|||||||
MEDIA_PLAYER_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(cv.Schema({}))
 | 
					MEDIA_PLAYER_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(cv.Schema({}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MEDIA_PLAYER_ACTION_SCHEMA = maybe_simple_id(
 | 
					MEDIA_PLAYER_ACTION_SCHEMA = maybe_simple_id({cv.GenerateID(): cv.use_id(MediaPlayer)})
 | 
				
			||||||
    {cv.Required(CONF_ID): cv.use_id(MediaPlayer)}
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@automation.register_action("media_player.play", PlayAction, MEDIA_PLAYER_ACTION_SCHEMA)
 | 
					@automation.register_action("media_player.play", PlayAction, MEDIA_PLAYER_ACTION_SCHEMA)
 | 
				
			||||||
@@ -58,12 +67,37 @@ MEDIA_PLAYER_ACTION_SCHEMA = maybe_simple_id(
 | 
				
			|||||||
    "media_player.pause", PauseAction, MEDIA_PLAYER_ACTION_SCHEMA
 | 
					    "media_player.pause", PauseAction, MEDIA_PLAYER_ACTION_SCHEMA
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@automation.register_action("media_player.stop", StopAction, MEDIA_PLAYER_ACTION_SCHEMA)
 | 
					@automation.register_action("media_player.stop", StopAction, MEDIA_PLAYER_ACTION_SCHEMA)
 | 
				
			||||||
 | 
					@automation.register_action(
 | 
				
			||||||
 | 
					    "media_player.volume_up", VolumeUpAction, MEDIA_PLAYER_ACTION_SCHEMA
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					@automation.register_action(
 | 
				
			||||||
 | 
					    "media_player.volume_down", VolumeDownAction, MEDIA_PLAYER_ACTION_SCHEMA
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
async def media_player_action(config, action_id, template_arg, args):
 | 
					async def media_player_action(config, action_id, template_arg, args):
 | 
				
			||||||
    var = cg.new_Pvariable(action_id, template_arg)
 | 
					    var = cg.new_Pvariable(action_id, template_arg)
 | 
				
			||||||
    await cg.register_parented(var, config[CONF_ID])
 | 
					    await cg.register_parented(var, config[CONF_ID])
 | 
				
			||||||
    return var
 | 
					    return var
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@automation.register_action(
 | 
				
			||||||
 | 
					    "media_player.volume_set",
 | 
				
			||||||
 | 
					    VolumeSetAction,
 | 
				
			||||||
 | 
					    cv.maybe_simple_value(
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            cv.GenerateID(): cv.use_id(MediaPlayer),
 | 
				
			||||||
 | 
					            cv.Required(CONF_VOLUME): cv.templatable(cv.percentage),
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        key=CONF_VOLUME,
 | 
				
			||||||
 | 
					    ),
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					async def media_player_volume_set_action(config, action_id, template_arg, args):
 | 
				
			||||||
 | 
					    var = cg.new_Pvariable(action_id, template_arg)
 | 
				
			||||||
 | 
					    await cg.register_parented(var, config[CONF_ID])
 | 
				
			||||||
 | 
					    volume = await cg.templatable(config[CONF_VOLUME], args, float)
 | 
				
			||||||
 | 
					    cg.add(var.set_volume(volume))
 | 
				
			||||||
 | 
					    return var
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@coroutine_with_priority(100.0)
 | 
					@coroutine_with_priority(100.0)
 | 
				
			||||||
async def to_code(config):
 | 
					async def to_code(config):
 | 
				
			||||||
    cg.add_global(media_player_ns.using)
 | 
					    cg.add_global(media_player_ns.using)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,28 +7,23 @@ namespace esphome {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace media_player {
 | 
					namespace media_player {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<typename... Ts> class PlayAction : public Action<Ts...>, public Parented<MediaPlayer> {
 | 
					#define MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(ACTION_CLASS, ACTION_COMMAND) \
 | 
				
			||||||
  void play(Ts... x) override {
 | 
					  template<typename... Ts> class ACTION_CLASS : public Action<Ts...>, public Parented<MediaPlayer> { \
 | 
				
			||||||
    this->parent_->make_call().set_command(MediaPlayerCommand::MEDIA_PLAYER_COMMAND_PLAY).perform();
 | 
					    void play(Ts... x) override { \
 | 
				
			||||||
  }
 | 
					      this->parent_->make_call().set_command(MediaPlayerCommand::MEDIA_PLAYER_COMMAND_##ACTION_COMMAND).perform(); \
 | 
				
			||||||
};
 | 
					    } \
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<typename... Ts> class ToggleAction : public Action<Ts...>, public Parented<MediaPlayer> {
 | 
					MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(PlayAction, PLAY)
 | 
				
			||||||
  void play(Ts... x) override {
 | 
					MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(PauseAction, PAUSE)
 | 
				
			||||||
    this->parent_->make_call().set_command(MediaPlayerCommand::MEDIA_PLAYER_COMMAND_TOGGLE).perform();
 | 
					MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(StopAction, STOP)
 | 
				
			||||||
  }
 | 
					MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(ToggleAction, TOGGLE)
 | 
				
			||||||
};
 | 
					MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(VolumeUpAction, VOLUME_UP)
 | 
				
			||||||
 | 
					MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(VolumeDownAction, VOLUME_DOWN)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<typename... Ts> class PauseAction : public Action<Ts...>, public Parented<MediaPlayer> {
 | 
					template<typename... Ts> class VolumeSetAction : public Action<Ts...>, public Parented<MediaPlayer> {
 | 
				
			||||||
  void play(Ts... x) override {
 | 
					  TEMPLATABLE_VALUE(float, volume)
 | 
				
			||||||
    this->parent_->make_call().set_command(MediaPlayerCommand::MEDIA_PLAYER_COMMAND_PAUSE).perform();
 | 
					  void play(Ts... x) override { this->parent_->make_call().set_volume(this->volume_.value(x...)).perform(); }
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template<typename... Ts> class StopAction : public Action<Ts...>, public Parented<MediaPlayer> {
 | 
					 | 
				
			||||||
  void play(Ts... x) override {
 | 
					 | 
				
			||||||
    this->parent_->make_call().set_command(MediaPlayerCommand::MEDIA_PLAYER_COMMAND_STOP).perform();
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}  // namespace media_player
 | 
					}  // namespace media_player
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,9 @@ enum MediaPlayerCommand : uint8_t {
 | 
				
			|||||||
  MEDIA_PLAYER_COMMAND_STOP = 2,
 | 
					  MEDIA_PLAYER_COMMAND_STOP = 2,
 | 
				
			||||||
  MEDIA_PLAYER_COMMAND_MUTE = 3,
 | 
					  MEDIA_PLAYER_COMMAND_MUTE = 3,
 | 
				
			||||||
  MEDIA_PLAYER_COMMAND_UNMUTE = 4,
 | 
					  MEDIA_PLAYER_COMMAND_UNMUTE = 4,
 | 
				
			||||||
  MEDIA_PLAYER_COMMAND_TOGGLE = 5
 | 
					  MEDIA_PLAYER_COMMAND_TOGGLE = 5,
 | 
				
			||||||
 | 
					  MEDIA_PLAYER_COMMAND_VOLUME_UP = 6,
 | 
				
			||||||
 | 
					  MEDIA_PLAYER_COMMAND_VOLUME_DOWN = 7,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
const char *media_player_command_to_string(MediaPlayerCommand command);
 | 
					const char *media_player_command_to_string(MediaPlayerCommand command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -114,6 +114,7 @@ void MQTTFanComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig
 | 
				
			|||||||
  if (this->state_->get_traits().supports_speed()) {
 | 
					  if (this->state_->get_traits().supports_speed()) {
 | 
				
			||||||
    root[MQTT_PERCENTAGE_COMMAND_TOPIC] = this->get_speed_level_command_topic();
 | 
					    root[MQTT_PERCENTAGE_COMMAND_TOPIC] = this->get_speed_level_command_topic();
 | 
				
			||||||
    root[MQTT_PERCENTAGE_STATE_TOPIC] = this->get_speed_level_state_topic();
 | 
					    root[MQTT_PERCENTAGE_STATE_TOPIC] = this->get_speed_level_state_topic();
 | 
				
			||||||
 | 
					    root[MQTT_SPEED_RANGE_MAX] = this->state_->get_traits().supported_speed_count();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
bool MQTTFanComponent::publish_state() {
 | 
					bool MQTTFanComponent::publish_state() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -115,7 +115,7 @@ void Nextion::set_backlight_brightness(float brightness) {
 | 
				
			|||||||
    ESP_LOGD(TAG, "Brightness out of bounds, percentage range 0-1.0");
 | 
					    ESP_LOGD(TAG, "Brightness out of bounds, percentage range 0-1.0");
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  this->add_no_result_to_queue_with_set("backlight_brightness", "dim", static_cast<int>(brightness * 100));
 | 
					  this->add_no_result_to_queue_with_printf_("backlight_brightness", "dim=%d", static_cast<int>(brightness * 100));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Nextion::set_auto_wake_on_touch(bool auto_wake) {
 | 
					void Nextion::set_auto_wake_on_touch(bool auto_wake) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
"""Constants used by esphome."""
 | 
					"""Constants used by esphome."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__version__ = "2022.6.0b1"
 | 
					__version__ = "2022.6.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
 | 
					ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -604,6 +604,14 @@ touchscreen:
 | 
				
			|||||||
      - logger.log:
 | 
					      - logger.log:
 | 
				
			||||||
          format: Touch at (%d, %d)
 | 
					          format: Touch at (%d, %d)
 | 
				
			||||||
          args: ["touch.x", "touch.y"]
 | 
					          args: ["touch.x", "touch.y"]
 | 
				
			||||||
 | 
					      - media_player.play:
 | 
				
			||||||
 | 
					      - media_player.pause:
 | 
				
			||||||
 | 
					      - media_player.stop:
 | 
				
			||||||
 | 
					      - media_player.toggle:
 | 
				
			||||||
 | 
					      - media_player.volume_up:
 | 
				
			||||||
 | 
					      - media_player.volume_down:
 | 
				
			||||||
 | 
					      - media_player.volume_set: 50%
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
media_player:
 | 
					media_player:
 | 
				
			||||||
  - platform: i2s_audio
 | 
					  - platform: i2s_audio
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user